Skip to content

Commit 0168729

Browse files
feat!: Adds closure support to Field definitions
Also removes codability of GraphQL types that now use closures, and removes TypeReference usage. Instead, use circular typing in Swift and Javascript approach where fields/interfaces are stored as closures and resolved realtime.
1 parent 91eb501 commit 0168729

18 files changed

+256
-562
lines changed

Sources/GraphQL/Execution/Execute.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ func getFieldDef(
12371237
}
12381238

12391239
// This field should exist because we passed validation before execution
1240-
guard let fieldDefinition = parentType.fields[fieldName] else {
1240+
guard let fieldDefinition = try parentType.getFields()[fieldName] else {
12411241
throw GraphQLError(
12421242
message: "Expected field definition not found: '\(fieldName)' on '\(parentType.name)'"
12431243
)

Sources/GraphQL/Execution/Values.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func coerceValue(value: Map, type: GraphQLInputType) throws -> Map {
157157
throw GraphQLError(message: "Must be dictionary to extract to an input type")
158158
}
159159

160-
let fields = objectType.fields
160+
let fields = try objectType.getFields()
161161

162162
var object = OrderedDictionary<String, Map>()
163163
for (fieldName, field) in fields {

Sources/GraphQL/Language/Parser.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,8 @@ func parseScalarExtensionDefinition(lexer: Lexer) throws -> ScalarExtensionDefin
11121112
definition: ScalarTypeDefinition(
11131113
name: name,
11141114
directives: directives
1115-
)
1115+
),
1116+
directives: directives
11161117
)
11171118
}
11181119

0 commit comments

Comments
 (0)