Repository navigation
Disabling introspection when multiple schemas are used #1150
Answered
by
Shane32
IvanInvenit
asked this question in
Q&A
|
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? |
Answered by
Shane32
Sep 5, 2024
Replies: 2 comments 1 reply
|
FYI, |
0 replies
|
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()); |
1 reply
Answer selected by
IvanInvenit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this should work: