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

Commit a8def22

Browse files
authored
Merge pull request #145 from graphql-java-kickstart/feature/124-disable-introspection-option
Added option to disable introspection query (fix #124)
2 parents 95b764b + 38a32c6 commit a8def22

File tree

6 files changed

+24
-5
lines changed

6 files changed

+24
-5
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.

build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
buildscript {
2121
repositories {
2222
mavenLocal()
23-
maven { url "http://dl.bintray.com/graphql-java-kickstart/releases" }
23+
mavenCentral()
24+
jcenter()
25+
maven { url "https://dl.bintray.com/graphql-java-kickstart/releases" }
2426
maven { url "https://plugins.gradle.org/m2/" }
2527
maven { url 'http://repo.spring.io/plugins-release' }
2628
}
@@ -45,8 +47,9 @@ subprojects {
4547

4648
repositories {
4749
mavenLocal()
50+
mavenCentral()
4851
jcenter()
49-
maven { url "http://dl.bintray.com/graphql-java-kickstart/releases" }
52+
maven { url "http://oss.jfrog.org/artifactory/oss-snapshot-local" }
5053
maven { url "http://repo.spring.io/libs-milestone" }
5154
}
5255

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ LIB_JUNIT_VER = 4.12
4141
LIB_SPRING_CORE_VER = 5.0.4.RELEASE
4242
LIB_SPRING_BOOT_VER = 2.0.5.RELEASE
4343
LIB_GRAPHQL_SERVLET_VER = 6.1.4
44-
LIB_GRAPHQL_JAVA_TOOLS_VER = 5.3.3
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)