diff --git a/src/main/kotlin/graphql/kickstart/tools/SchemaParser.kt b/src/main/kotlin/graphql/kickstart/tools/SchemaParser.kt index 34ff518f..6dbf549e 100644 --- a/src/main/kotlin/graphql/kickstart/tools/SchemaParser.kt +++ b/src/main/kotlin/graphql/kickstart/tools/SchemaParser.kt @@ -10,7 +10,6 @@ import graphql.language.* import graphql.schema.* import graphql.schema.idl.RuntimeWiring import graphql.schema.idl.ScalarInfo -import graphql.schema.idl.SchemaGeneratorHelperExt import graphql.schema.visibility.NoIntrospectionGraphqlFieldVisibility import org.slf4j.LoggerFactory import kotlin.reflect.KClass @@ -58,7 +57,6 @@ class SchemaParser internal constructor( private val codeRegistryBuilder = GraphQLCodeRegistry.newCodeRegistry() - private val schemaGeneratorHelper = SchemaGeneratorHelperExt() private val schemaGeneratorDirectiveHelper = SchemaGeneratorDirectiveHelper() private val schemaDirectiveParameters = SchemaGeneratorDirectiveHelper.Parameters(null, runtimeWiring, null, codeRegistryBuilder) @@ -307,18 +305,21 @@ class SchemaParser internal constructor( names.add(directive.name) val graphQLDirective = GraphQLDirective.newDirective() .name(directive.name) + .description(getDocumentation(directive, options)) + .comparatorRegistry(runtimeWiring.comparatorRegistry) + .validLocation(directiveLocation) .apply { directive.arguments.forEach { arg -> argument(GraphQLArgument.newArgument() .name(arg.name) .type(buildDirectiveInputType(arg.value)) + .valueLiteral(arg.value) .build()) } } .build() - - output.add(schemaGeneratorHelper.buildAppliedDirective(directive, graphQLDirective, directiveLocation, runtimeWiring.comparatorRegistry)) + output.add(graphQLDirective) } } @@ -392,12 +393,12 @@ class SchemaParser internal constructor( } private fun determineInputType(typeDefinition: Type<*>, inputObjects: List, referencingInputObjects: Set) = - determineInputType(GraphQLInputType::class, typeDefinition, permittedTypesForInputObject, inputObjects, referencingInputObjects) as GraphQLInputType + determineInputType(GraphQLInputType::class, typeDefinition, permittedTypesForInputObject, inputObjects, referencingInputObjects) private fun determineInputType(expectedType: KClass, typeDefinition: Type<*>, allowedTypeReferences: Set, inputObjects: List, - referencingInputObjects: Set): GraphQLType = + referencingInputObjects: Set): GraphQLInputType = when (typeDefinition) { is ListType -> GraphQLList(determineType(expectedType, typeDefinition.type, allowedTypeReferences, inputObjects)) is NonNullType -> GraphQLNonNull(determineType(expectedType, typeDefinition.type, allowedTypeReferences, inputObjects)) diff --git a/src/main/kotlin/graphql/kickstart/tools/util/Utils.kt b/src/main/kotlin/graphql/kickstart/tools/util/Utils.kt index eb72f885..ba5e22a5 100644 --- a/src/main/kotlin/graphql/kickstart/tools/util/Utils.kt +++ b/src/main/kotlin/graphql/kickstart/tools/util/Utils.kt @@ -50,9 +50,9 @@ internal val Class<*>.declaredNonProxyMethods: List } } -internal fun getDocumentation(node: AbstractDescribedNode<*>, options: SchemaParserOptions): String? = +internal fun getDocumentation(node: AbstractNode<*>, options: SchemaParserOptions): String? = when { - node.description != null -> node.description.content + node is AbstractDescribedNode<*> && node.description != null -> node.description.content !options.useCommentsForDescriptions -> null node.comments.isNullOrEmpty() -> null else -> node.comments.asSequence() diff --git a/src/main/kotlin/graphql/schema/idl/SchemaGeneratorHelperExt.kt b/src/main/kotlin/graphql/schema/idl/SchemaGeneratorHelperExt.kt deleted file mode 100644 index 0d07a2d9..00000000 --- a/src/main/kotlin/graphql/schema/idl/SchemaGeneratorHelperExt.kt +++ /dev/null @@ -1,21 +0,0 @@ -package graphql.schema.idl - -import graphql.introspection.Introspection -import graphql.language.Directive -import graphql.schema.GraphQLDirective -import graphql.schema.GraphqlTypeComparatorRegistry -import graphql.schema.idl.RuntimeWiring.MOCKED_WIRING -import graphql.schema.idl.SchemaGenerator.Options.defaultOptions - -class SchemaGeneratorHelperExt : SchemaGeneratorHelper() { - // Re-expose a package protected method as public - fun buildAppliedDirective(directive: Directive, - graphQLDirective: GraphQLDirective, - directiveLocation: Introspection.DirectiveLocation, - comparatorRegistry: GraphqlTypeComparatorRegistry): GraphQLDirective { - // Note: repeatable directives (new feature in graphql-java 16) likely don't work, - // since we don't pass in the full set of discovered directives - val context = BuildContext(TypeDefinitionRegistry(), MOCKED_WIRING, emptyMap(), defaultOptions()) - return super.buildAppliedDirective(context, directive, setOf(graphQLDirective), directiveLocation, comparatorRegistry) - } -}