resolveViaServiceUpdate<Value, Serialized> function

GraphQLFieldResolver<Value?, Serialized> resolveViaServiceUpdate<Value, Serialized>(
  1. Service<dynamic, Value?> service, {
  2. String idField = 'id',
})

A GraphQL resolver that updates a single value from an Angel service.

This resolver should be used on a field with at least the following inputs:

  • id: a graphQLId or graphQLString
  • data: a GraphQLObjectType corresponding to the format of data to be passed to update

The arguments passed to the resolver will be forwarded to the service, and the service will receive Providers.graphql.

Keep in mind that update overwrites existing contents. To avoid this, use resolveViaServiceModify instead.

Implementation

GraphQLFieldResolver<Value?, Serialized>
    resolveViaServiceUpdate<Value, Serialized>(Service<dynamic, Value?> service,
        {String idField = 'id'}) {
  return (_, arguments) async {
    var requestInfo = _fetchRequestInfo(arguments);
    var params = {'query': _getQuery(arguments), 'provider': Providers.graphQL}
      ..addAll(requestInfo);
    var id = arguments.remove(idField);
    return await service.update(id, arguments['data'] as Value?, params);
  };
}