Disabling introspection when multiple schemas are used #1150
-
I use GraphQL.Server.All v8.0.2 and ASP.NET Core 8. In my project there are two schemas, each on its own URL. I will refer to them as Schema1 (accessible on /s1/graphql) and Schema2 (accessible on /s2/graphql) for simplicity. I would like to disable introspection only on Schema2. I wrote a custom validation rule according to the docs:
How can i add this rule to just Schema2? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
FYI, |
Beta Was this translation helpful? Give feedback.
-
I think this should work: services.AddGraphQL(b => b
// existing code to register schemas, etc
.AddSchema<Schema1>()
.AddSchema<Schema2>()
// configure a validation rule for a single schema
.ConfigureExecutionOptions(o =>
{
if (o.Schema is Schema2)
{
o.ValidationRules = (o.ValidationRules ?? DocumentValidator.CoreRules).Append(NoIntrospectionValidationRule.Instance);
}
})
// other stuff
.AddSystemTextJson()); |
Beta Was this translation helpful? Give feedback.
I think this should work: