Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 2 additions & 27 deletions src/main/kotlin/graphql/kickstart/tools/SchemaObjects.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,13 @@ data class SchemaObjects @JvmOverloads constructor(
val query: GraphQLObjectType,
val mutation: GraphQLObjectType?,
val subscription: GraphQLObjectType?,
val dictionary: Set<GraphQLType>,
val dictionary: Set<GraphQLNamedType>,
val directives: Set<GraphQLDirective>,
val codeRegistryBuilder: GraphQLCodeRegistry.Builder,
val description: String?,
// directives applied to the schema itself, e.g. `extend schema @link(...)`
val schemaAppliedDirectives: List<GraphQLAppliedDirective> = 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<GraphQLType> = this.dictionary,
directives: Set<GraphQLDirective> = 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<GraphQLNamedType> in the next major version and remove this cast
@Suppress("UNCHECKED_CAST")
private fun namedDictionary(): Set<GraphQLNamedType> = dictionary as Set<GraphQLNamedType>

/**
* Makes a GraphQLSchema with query, mutation and subscription.
*/
Expand All @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/graphql/kickstart/tools/SchemaParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<GraphQLType>) + inputObjects + enums + interfaces + unions + scalars
val types = additionalObjects.toSet<GraphQLNamedType>() + 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())
Expand Down Expand Up @@ -145,7 +145,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 }
)
}

Expand Down
Loading