Graphql-java
With graphql-java, you build a GraphQLSchema using a GraphQLSchema.Builder. You need to set the builder visibility for the introspection field before building to disable the introspection query.
GraphQLSchema.Builder builder = GraphQLSchema.newSchema()
.query(query)
.mutation(mutation)
.subscription(subscription)
.additionalTypes(dictionary);
builder.fieldVisibility(NoIntrospectionGraphqlFieldVisibility.NO_INTROSPECTION_FIELD_VISIBILITY);
GraphQLSchema = builder.build();
You can use the graphql-java-tools implementation as a reference.
Graphql-java-tools
With graphql-java-tools, you build a SchemaParser using a SchemaParserBuilder. The SchemaParserBuilder needs a SchemaParserOptions object. When building the SchemaParserOptions, you can enable or disable the introspection query. Here is a very simplified implementation.
SchemaParserBuilder builder = new SchemaParserBuilder();
final SchemaParserOptions.Builder optionsBuilder = newOptions();
optionsBuilder.introspectionEnabled(introspectionEnabled);
return builder.options(optionsBuilder.build()).build();
You can use the graphql-spring-boot implementation as a reference.
Graphql-spring-boot
If you are using graphql-spring-boot, according to the graphql-java-tools README, you can disable the introspection query by setting the graphql.tools.introspection-enabled property to false in your application.properties or application.yml file.
graphql:
tools:
schema-location-pattern: "**/*.graphqls"
# Enable or disable the introspection query. Disabling it puts your server in contravention of the GraphQL
# specification and expectations of most clients, so use this option with caution
introspection-enabled: false
Graphql-spqr
With Graphql-spqr, the idea is the same as in graphql-java: the setting the builder field visibility. See my answer to this question for how to implement it.
Netflix DGS:
5
dgs:
graphql:
introspection:
enabled: false