Skip to content

Commit ab8b58b

Browse files
authored
Merge pull request #386 from graphql-java-kickstart/feature/field-visibility
Feature/field visibility
2 parents 7b0e758 + 11c23df commit ab8b58b

File tree

4 files changed

+422
-414
lines changed

4 files changed

+422
-414
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.graphql-java-kickstart</groupId>
66
<artifactId>graphql-java-tools</artifactId>
7-
<version>6.0.3-SNAPSHOT</version>
7+
<version>6.1.0-SNAPSHOT</version>
88
<packaging>jar</packaging>
99

1010
<name>GraphQL Java Tools</name>

src/main/kotlin/graphql/kickstart/tools/SchemaObjects.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import graphql.schema.GraphQLCodeRegistry
44
import graphql.schema.GraphQLObjectType
55
import graphql.schema.GraphQLSchema
66
import graphql.schema.GraphQLType
7-
import graphql.schema.visibility.NoIntrospectionGraphqlFieldVisibility
87

98
/**
109
* @author Andrew Potter
@@ -14,11 +13,7 @@ data class SchemaObjects(val query: GraphQLObjectType, val mutation: GraphQLObje
1413
/**
1514
* Makes a GraphQLSchema with query, mutation and subscription.
1615
*/
17-
fun toSchema(introspectionEnabled: Boolean): GraphQLSchema {
18-
if (!introspectionEnabled) {
19-
codeRegistryBuilder.fieldVisibility(NoIntrospectionGraphqlFieldVisibility.NO_INTROSPECTION_FIELD_VISIBILITY)
20-
}
21-
16+
fun toSchema(): GraphQLSchema {
2217
return GraphQLSchema.newSchema()
2318
.query(query)
2419
.mutation(mutation)

src/main/kotlin/graphql/kickstart/tools/SchemaParser.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import graphql.schema.*
66
import graphql.schema.idl.RuntimeWiring
77
import graphql.schema.idl.ScalarInfo
88
import graphql.schema.idl.SchemaGeneratorHelper
9+
import graphql.schema.visibility.NoIntrospectionGraphqlFieldVisibility
910
import org.slf4j.LoggerFactory
1011
import java.util.*
1112
import kotlin.reflect.KClass
@@ -62,9 +63,13 @@ class SchemaParser internal constructor(scanResult: ScannedSchemaObjects, privat
6263
* Parses the given schema with respect to the given dictionary and returns GraphQL objects.
6364
*/
6465
fun parseSchemaObjects(): SchemaObjects {
66+
if (!options.introspectionEnabled) {
67+
codeRegistryBuilder.fieldVisibility(NoIntrospectionGraphqlFieldVisibility.NO_INTROSPECTION_FIELD_VISIBILITY)
68+
}
69+
// this overrides the above introspection enabled setting obviously... todo: add documentation
70+
options.fieldVisilibity?.let { codeRegistryBuilder.fieldVisibility(it) }
6571

6672
// Create GraphQL objects
67-
// val inputObjects = inputObjectDefinitions.map { createInputObject(it, listOf())}
6873
val inputObjects: MutableList<GraphQLInputObjectType> = mutableListOf()
6974
inputObjectDefinitions.forEach {
7075
if (inputObjects.none { io -> io.name == it.name }) {
@@ -101,7 +106,7 @@ class SchemaParser internal constructor(scanResult: ScannedSchemaObjects, privat
101106
/**
102107
* Parses the given schema with respect to the given dictionary and returns a GraphQLSchema
103108
*/
104-
fun makeExecutableSchema(): GraphQLSchema = parseSchemaObjects().toSchema(options.introspectionEnabled)
109+
fun makeExecutableSchema(): GraphQLSchema = parseSchemaObjects().toSchema()
105110

106111
/**
107112
* Returns any unused type definitions that were found in the schema

0 commit comments

Comments
 (0)