/// <summary> /// Adds filtering support. /// </summary> /// <param name="builder"> /// The <see cref="ISchemaBuilder"/>. /// </param> /// <param name="name"> /// The filter convention name. /// </param> /// <typeparam name="TConvention"> /// The concrete filter convention type. /// </typeparam> /// <returns> /// Returns the <see cref="ISchemaBuilder"/>. /// </returns> public static ISchemaBuilder AddProjections <TConvention>( this ISchemaBuilder builder, string?name = null) where TConvention : class, IProjectionConvention => builder .TryAddTypeInterceptor <ProjectionTypeInterceptor>() .TryAddConvention <IProjectionConvention, TConvention>(name);
/// <summary> /// Adds filtering support. /// </summary> /// <param name="builder"> /// The <see cref="ISchemaBuilder"/>. /// </param> /// <param name="configure"> /// Configures the convention. /// </param> /// <param name="name"> /// The filter convention name. /// </param> /// <returns> /// Returns the <see cref="ISchemaBuilder"/>. /// </returns> public static ISchemaBuilder AddProjections( this ISchemaBuilder builder, Action <IProjectionConventionDescriptor> configure, string?name = null) => builder .TryAddTypeInterceptor <ProjectionTypeInterceptor>() .TryAddConvention <IProjectionConvention>( sp => new ProjectionConvention(configure), name);
public static ISchemaBuilder TryAddTypeInterceptor <T>( this ISchemaBuilder builder) where T : ITypeInitializationInterceptor { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } return(builder.TryAddTypeInterceptor(typeof(T))); }
/// <summary> /// Adds support for Apollo Federation to the schema. /// </summary> /// <param name="builder"> /// The <see cref="ISchemaBuilder"/>. /// </param> /// <returns> /// Returns the <see cref="ISchemaBuilder"/>. /// </returns> /// <exception cref="ArgumentNullException"> /// The <paramref name="builder"/> is <c>null</c>. /// </exception> public static ISchemaBuilder AddApolloFederation( this ISchemaBuilder builder) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } builder.AddType <EntityType>(); builder.AddType <ExternalDirectiveType>(); builder.AddType <ProvidesDirectiveType>(); builder.AddType <KeyDirectiveType>(); builder.AddType <FieldSetType>(); builder.AddType <RequiresDirectiveType>(); builder.TryAddTypeInterceptor <EntityTypeInterceptor>(); return(builder); }
/// <summary> /// Enables relay schema style. /// </summary> public static ISchemaBuilder EnableRelaySupport( this ISchemaBuilder schemaBuilder, RelayOptions options = null) { options ??= new(); if (options.AddQueryFieldToMutationPayloads) { schemaBuilder.TryAddTypeInterceptor <QueryFieldTypeInterceptor>(); } return(schemaBuilder .SetContextData(IsRelaySupportEnabled, 1) .SetRelayOptions(options) .TryAddTypeInterceptor <NodeFieldTypeInterceptor>() .AddType <NodeType>()); }
private async ValueTask <ISchema> CreateSchemaAsync( NameString schemaName, RequestExecutorSetup options, IServiceProvider serviceProvider, CancellationToken cancellationToken) { if (options.Schema is not null) { AssertSchemaNameValid(options.Schema, schemaName); return(options.Schema); } ISchemaBuilder schemaBuilder = options.SchemaBuilder ?? new SchemaBuilder(); schemaBuilder.AddServices(serviceProvider); foreach (SchemaBuilderAction action in options.SchemaBuilderActions) { if (action.Action is { } configure) { configure(serviceProvider, schemaBuilder); } if (action.AsyncAction is { } configureAsync) { await configureAsync(serviceProvider, schemaBuilder, cancellationToken) .ConfigureAwait(false); } } schemaBuilder.TryAddTypeInterceptor(new SetSchemaNameInterceptor(schemaName)); ISchema schema = schemaBuilder.Create(); AssertSchemaNameValid(schema, schemaName); return(schema); }
public static ISchemaBuilder AddGlobalObjectIdentification(this ISchemaBuilder schemaBuilder) { return(schemaBuilder .TryAddTypeInterceptor <NodeFieldTypeInterceptor>() .AddType <NodeType>()); }