Skip to content

Commit

Permalink
allow specifying introspectionEnabled when calling the AddGraphQLSc…
Browse files Browse the repository at this point in the history
…hema extension method(s)
  • Loading branch information
eharshosh committed Jun 1, 2024
1 parent 957e4cb commit aaeab1c
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ public static class EntityGraphQLAspNetServiceCollectionExtensions
/// <param name="configure">Function to further configure your schema</param>
/// <typeparam name="TSchemaContext"></typeparam>
/// <returns></returns>
public static IServiceCollection AddGraphQLSchema<TSchemaContext>(this IServiceCollection serviceCollection, Action<SchemaProvider<TSchemaContext>>? configure = null)
public static IServiceCollection AddGraphQLSchema<TSchemaContext>(this IServiceCollection serviceCollection,
Action<SchemaProvider<TSchemaContext>>? configure = null, bool introspectionEnabled = true)
{
serviceCollection.AddGraphQLSchema<TSchemaContext>(options =>
{
options.ConfigureSchema = configure;
});
}, introspectionEnabled);

return serviceCollection;
}
Expand All @@ -34,7 +35,8 @@ public static IServiceCollection AddGraphQLSchema<TSchemaContext>(this IServiceC
/// <param name="serviceCollection"></param>
/// <param name="configure">Callback to configure the AddGraphQLOptions</param>
/// <returns></returns>
public static IServiceCollection AddGraphQLSchema<TSchemaContext>(this IServiceCollection serviceCollection, Action<AddGraphQLOptions<TSchemaContext>> configure)
public static IServiceCollection AddGraphQLSchema<TSchemaContext>(this IServiceCollection serviceCollection,
Action<AddGraphQLOptions<TSchemaContext>> configure, bool introspectionEnabled = true)
{
serviceCollection.TryAddSingleton<IGraphQLRequestDeserializer>(new DefaultGraphQLRequestDeserializer());
serviceCollection.TryAddSingleton<IGraphQLResponseSerializer>(new DefaultGraphQLResponseSerializer());
Expand All @@ -47,9 +49,11 @@ public static IServiceCollection AddGraphQLSchema<TSchemaContext>(this IServiceC
configure(options);

var schema = new SchemaProvider<TSchemaContext>(
new PolicyOrRoleBasedAuthorization(authService), options.FieldNamer,
new PolicyOrRoleBasedAuthorization(authService),
options.FieldNamer,
introspectionEnabled: introspectionEnabled,
isDevelopment: webHostEnvironment?.IsEnvironment("Development") ?? true
);
);
options.PreBuildSchemaFromContext?.Invoke(schema);
if (options.AutoBuildSchemaFromContext)
schema.PopulateFromContext(options);
Expand Down

0 comments on commit aaeab1c

Please sign in to comment.