resolveViaServiceCreate<Value, Serialized> function

GraphQLFieldResolver<Value?, Serialized> resolveViaServiceCreate<Value, Serialized>(
  1. Service<dynamic, Value?> service
)

A GraphQL resolver that creates a single value in an Angel service.

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

  • data: a GraphQLObjectType corresponding to the format of data to be passed to create

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

Implementation

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