public ModelConventionInputBuilder <TSource> Delete <TDeleteInput, TDeleteOutput>( Func <TDeleteInput, TSource> mapDelete, Func <TSource, TDeleteOutput> transform) { _deleteSetupAction = () => { var fieldName = $"delete{GetTypeName()}"; if (_objectGraphType.HasField(fieldName)) { return; } _objectGraphType.FieldAsync <ModelConventionType <TDeleteOutput> >(fieldName, description: $"Deletes a single {GetTypeName()} instance.", arguments: _queryArgumentsBuilder.BuildNonNull <TDeleteInput>(_sourceName), resolve: async context => await _fieldMutationResolver.DeleteAsync(context, _sourceName, mapDelete, transform)); }; return(this); }
internal ModelConventionInputBuilder( ObjectGraphType objectGraphType, IGraphQlRepositoryProvider graphQlRepositoryProviderProvider, ILogger logger, ISearchMappedModels searchMappedModels, IQueryArgumentsBuilder queryArgumentsBuilder, IFieldMutationResolver fieldMutationResolver) { _objectGraphType = objectGraphType; _graphQlRepositoryProvider = graphQlRepositoryProviderProvider; _logger = logger; _searchMappedModels = searchMappedModels; _queryArgumentsBuilder = queryArgumentsBuilder; _fieldMutationResolver = fieldMutationResolver; _sourceName = typeof(TSource).Name.ToLower(); // Default setup for delete. _deleteSetupAction = () => { var fieldName = $"delete{GetTypeName()}"; if (_objectGraphType.HasField(fieldName)) { return; } _objectGraphType.FieldAsync <ModelConventionType <TSource> >(fieldName, description: $"Deletes a single {GetTypeName()} instance.", arguments: _queryArgumentsBuilder.BuildNonNull <TSource>(_sourceName), resolve: async context => await _fieldMutationResolver.DeleteAsync <TSource>(context, _sourceName)); }; }