Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 4e69149

Browse files
committed
Added option to disable introspection query (fix #124)
Depends on graphql-java-tools v5.3.4
1 parent 6320bbd commit 4e69149

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ Available Spring Boot configuration parameters (either `application.yml` or `app
167167
graphql:
168168
tools:
169169
schemaLocationPattern: "**/*.graphqls"
170+
# Enable or disable the introspection query. Disabling it puts your server in contravention of the GraphQL
171+
# specification and expectations of most clients, so use this option with caution
172+
introspectionEnabled: true
170173
```
171174
By default GraphQL tools uses the location pattern `**/*.graphqls` to scan for GraphQL schemas on the classpath.
172175
Use the `schemaLocationPattern` property to customize this pattern.

example-graphql-tools/src/main/resources/application.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ spring:
33
name: graphql-java-tools-app
44
server:
55
port: 9000
6-
servlet:
7-
context-path: /abc
86
graphiql:
97
headers:
108
Authorization: "Bearer 05bd9a5f3fe0408f89520946b0fe1b06"

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ LIB_GRAPHQL_JAVA_VER = 9.2
4040
LIB_JUNIT_VER = 4.12
4141
LIB_SPRING_CORE_VER = 5.0.4.RELEASE
4242
LIB_SPRING_BOOT_VER = 2.0.5.RELEASE
43-
LIB_GRAPHQL_SERVLET_VER = 6.1.4
44-
LIB_GRAPHQL_JAVA_TOOLS_VER = 5.3.3
43+
LIB_GRAPHQL_SERVLET_VER = 6.2.0-SNAPSHOT
44+
LIB_GRAPHQL_JAVA_TOOLS_VER = 5.3.4-SNAPSHOT
4545
LIB_COMMONS_IO_VER = 2.6
4646

4747
GRADLE_WRAPPER_VER = 4.7

graphql-spring-boot-autoconfigure/src/main/java/com/oembedler/moon/graphql/boot/GraphQLJavaToolsAutoConfiguration.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import graphql.schema.GraphQLSchema;
99
import graphql.servlet.GraphQLSchemaProvider;
1010
import org.springframework.beans.factory.annotation.Autowired;
11+
import org.springframework.beans.factory.annotation.Value;
1112
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
1213
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
1314
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -39,6 +40,9 @@ public class GraphQLJavaToolsAutoConfiguration {
3940
@Autowired(required = false)
4041
private SchemaParserOptions options;
4142

43+
@Value("${graphql.tools.introspectionEnabled:true}")
44+
private boolean introspectionEnabled;
45+
4246
@Bean
4347
@ConditionalOnMissingBean
4448
public SchemaStringProvider schemaStringProvider() {
@@ -67,6 +71,7 @@ public SchemaParser schemaParser(
6771
} else if (perFieldObjectMapperProvider != null) {
6872
final SchemaParserOptions.Builder optionsBuilder =
6973
newOptions().objectMapperProvider(perFieldObjectMapperProvider);
74+
optionsBuilder.introspectionEnabled(introspectionEnabled);
7075
builder.options(optionsBuilder.build());
7176
}
7277

graphql-spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@
4444
"name": "graphql.servlet.maxQueryDepth",
4545
"defaultValue": null,
4646
"type": "java.lang.Integer"
47+
},
48+
{
49+
"name": "graphql.tools.schemaLocationPattern",
50+
"defaultValue": "**/*.graphqls",
51+
"type": "java.lang.String"
52+
},
53+
{
54+
"name": "graphql.tools.introspectionEnabled",
55+
"defaultValue": true,
56+
"type": "java.lang.Boolean"
4757
}
4858
]
4959
}

0 commit comments

Comments
 (0)