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

Commit fa370cc

Browse files
committed
Reinstate possibility to disable introspection fix #402
1 parent fe06ca3 commit fa370cc

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,5 @@ server:
66
graphql:
77
servlet:
88
exception-handlers-enabled: true
9-
tracing-enabled: metrics-only
10-
graphiql:
11-
headers:
12-
Authorization: "Bearer 05bd9a5f3fe0408f89520946b0fe1b06"
13-
props:
14-
variables:
15-
headerEditorEnabled: true
16-
logging:
17-
level:
18-
com:
19-
oembedler:
20-
moon:
21-
graphql:
22-
boot:
23-
error: debug
9+
tools:
10+
introspection-enabled: false

graphql-kickstart-spring-boot-autoconfigure-tools/src/main/java/graphql/kickstart/tools/boot/GraphQLJavaToolsAutoConfiguration.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import graphql.schema.GraphQLSchema;
2020
import graphql.schema.idl.SchemaDirectiveWiring;
2121
import graphql.schema.visibility.GraphqlFieldVisibility;
22+
import graphql.schema.visibility.NoIntrospectionGraphqlFieldVisibility;
2223
import java.io.IOException;
2324
import java.util.List;
2425
import java.util.Optional;
@@ -167,4 +168,12 @@ public PerFieldObjectMapperProvider perFieldObjectMapperProvider(ObjectMapper ob
167168
public GraphQLSchema graphQLSchema(SchemaParser schemaParser) {
168169
return schemaParser.makeExecutableSchema();
169170
}
171+
172+
@Bean
173+
@ConditionalOnProperty(value = "graphql.tools.introspection-enabled", havingValue = "false")
174+
GraphqlFieldVisibility disableIntrospection() {
175+
log.warn("GraphQL introspection query disabled! This puts your server in contravention of the "
176+
+ "GraphQL specification and expectations of most clients, so use this option with caution");
177+
return new NoIntrospectionGraphqlFieldVisibility();
178+
}
170179
}

graphql-kickstart-spring-boot-autoconfigure-tools/src/main/java/graphql/kickstart/tools/boot/GraphQLToolsProperties.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
import lombok.Data;
44
import org.springframework.boot.context.properties.ConfigurationProperties;
5-
import org.springframework.context.annotation.Configuration;
65

76
@Data
87
@ConfigurationProperties(prefix = "graphql.tools")
98
class GraphQLToolsProperties {
109

11-
private String schemaLocationPattern = "**/*.graphqls";
12-
/** @deprecated Set graphql.tools.schema-parser-options.introspection-enabled instead */
13-
@Deprecated
14-
private boolean introspectionEnabled = true;
15-
private boolean useDefaultObjectmapper = true;
10+
private String schemaLocationPattern = "**/*.graphqls";
11+
/**
12+
* Enable or disable the introspection query. Disabling it puts your server in contravention of
13+
* the GraphQL specification and expectations of most clients, so use this option with caution
14+
*/
15+
private boolean introspectionEnabled = true;
16+
private boolean useDefaultObjectmapper = true;
1617

1718
}

0 commit comments

Comments
 (0)