From f78d954b8aa888e58ed42c3fba05d10582c5d5ad Mon Sep 17 00:00:00 2001 From: Oryan Date: Fri, 23 Oct 2026 20:29:45 -0400 Subject: [PATCH] Make SchemaObjects.dictionary a Set --- .../graphql/kickstart/tools/SchemaObjects.kt | 29 ++----------------- .../graphql/kickstart/tools/SchemaParser.kt | 4 +-- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/src/main/kotlin/graphql/kickstart/tools/SchemaObjects.kt b/src/main/kotlin/graphql/kickstart/tools/SchemaObjects.kt index 9530d388..f4a00c3c 100644 --- a/src/main/kotlin/graphql/kickstart/tools/SchemaObjects.kt +++ b/src/main/kotlin/graphql/kickstart/tools/SchemaObjects.kt @@ -9,38 +9,13 @@ data class SchemaObjects @JvmOverloads constructor( val query: GraphQLObjectType, val mutation: GraphQLObjectType?, val subscription: GraphQLObjectType?, - val dictionary: Set, + val dictionary: Set, val directives: Set, val codeRegistryBuilder: GraphQLCodeRegistry.Builder, val description: String?, // directives applied to the schema itself, e.g. `extend schema @link(...)` val schemaAppliedDirectives: List = emptyList() ) { - // keeps the copy() signature from before schemaAppliedDirectives was added, for binary compatibility - @Deprecated("Kept for binary compatibility", level = DeprecationLevel.HIDDEN) - fun copy( - query: GraphQLObjectType = this.query, - mutation: GraphQLObjectType? = this.mutation, - subscription: GraphQLObjectType? = this.subscription, - dictionary: Set = this.dictionary, - directives: Set = this.directives, - codeRegistryBuilder: GraphQLCodeRegistry.Builder = this.codeRegistryBuilder, - description: String? = this.description - ) = copy( - query = query, - mutation = mutation, - subscription = subscription, - dictionary = dictionary, - directives = directives, - codeRegistryBuilder = codeRegistryBuilder, - description = description, - schemaAppliedDirectives = schemaAppliedDirectives - ) - - // TODO change dictionary to Set in the next major version and remove this cast - @Suppress("UNCHECKED_CAST") - private fun namedDictionary(): Set = dictionary as Set - /** * Makes a GraphQLSchema with query, mutation and subscription. */ @@ -57,7 +32,7 @@ data class SchemaObjects @JvmOverloads constructor( private fun newSchema(): GraphQLSchema.Builder = GraphQLSchema.newSchema() .description(description) .query(query) - .additionalTypes(namedDictionary()) + .additionalTypes(dictionary) .additionalDirectives(directives) .withSchemaAppliedDirectives(schemaAppliedDirectives) .codeRegistry(codeRegistryBuilder.build()) diff --git a/src/main/kotlin/graphql/kickstart/tools/SchemaParser.kt b/src/main/kotlin/graphql/kickstart/tools/SchemaParser.kt index d471de9d..49692260 100644 --- a/src/main/kotlin/graphql/kickstart/tools/SchemaParser.kt +++ b/src/main/kotlin/graphql/kickstart/tools/SchemaParser.kt @@ -115,7 +115,7 @@ class SchemaParser internal constructor( val additionalObjects = objects.filter { o -> o != query && o != subscription && o != mutation } - val types = (additionalObjects.toSet() as Set) + inputObjects + enums + interfaces + unions + scalars + val types = additionalObjects.toSet() + inputObjects + enums + interfaces + unions + scalars // Directives applied to the schema itself, e.g. `extend schema @link(...)`. Only GraphQLAppliedDirectives are built here, not // the deprecated GraphQLDirective ones: graphql-java doesn't resolve type references in those, so enum arguments would fail. val schemaAppliedDirectives = sdlDirectives.schemaAppliedDirectives(rootInfo.getDirectives()) @@ -144,7 +144,7 @@ class SchemaParser internal constructor( query = wired[schemaObjects.query.name] as GraphQLObjectType? ?: schemaObjects.query, mutation = schemaObjects.mutation?.let { wired[it.name] as GraphQLObjectType? ?: it }, subscription = schemaObjects.subscription?.let { wired[it.name] as GraphQLObjectType? ?: it }, - dictionary = schemaObjects.dictionary.mapTo(linkedSetOf()) { wired[(it as GraphQLNamedType).name] ?: it } + dictionary = schemaObjects.dictionary.mapTo(linkedSetOf()) { wired[it.name] ?: it } ) }