@@ -359,23 +359,21 @@ func buildExecutionContext(
359
359
360
360
for definition in documentAST. definitions {
361
361
switch definition {
362
- case let definition as OperationDefinition :
362
+ case . executableDefinition ( . operation ( let definition) ) :
363
363
guard !( operationName == nil && possibleOperation != nil ) else {
364
364
throw GraphQLError (
365
365
message: " Must provide operation name if query contains multiple operations. "
366
366
)
367
367
}
368
-
368
+
369
369
if operationName == nil || definition. name? . value == operationName {
370
370
possibleOperation = definition
371
371
}
372
-
373
- case let definition as FragmentDefinition :
372
+ case . executableDefinition( . fragment( let definition) ) :
374
373
fragments [ definition. name. value] = definition
375
-
376
374
default :
377
375
throw GraphQLError (
378
- message: " GraphQL cannot execute a request containing a \( definition. kind ) . " ,
376
+ message: " GraphQL cannot execute a request containing a \( definition) . " ,
379
377
nodes: [ definition]
380
378
)
381
379
}
@@ -502,7 +500,7 @@ func collectFields(
502
500
503
501
for selection in selectionSet. selections {
504
502
switch selection {
505
- case let field as Field :
503
+ case . field ( let field) :
506
504
let shouldInclude = try shouldIncludeNode (
507
505
exeContext: exeContext,
508
506
directives: field. directives
@@ -519,7 +517,7 @@ func collectFields(
519
517
}
520
518
521
519
fields [ name] ? . append ( field)
522
- case let inlineFragment as InlineFragment :
520
+ case . inlineFragment ( let inlineFragment) :
523
521
let shouldInclude = try shouldIncludeNode (
524
522
exeContext: exeContext,
525
523
directives: inlineFragment. directives
@@ -542,43 +540,41 @@ func collectFields(
542
540
fields: & fields,
543
541
visitedFragmentNames: & visitedFragmentNames
544
542
)
545
- case let fragmentSpread as FragmentSpread :
543
+ case . fragmentSpread ( let fragmentSpread) :
546
544
let fragmentName = fragmentSpread. name. value
547
-
545
+
548
546
let shouldInclude = try shouldIncludeNode (
549
547
exeContext: exeContext,
550
548
directives: fragmentSpread. directives
551
549
)
552
-
550
+
553
551
guard visitedFragmentNames [ fragmentName] == nil && shouldInclude else {
554
552
continue
555
553
}
556
-
554
+
557
555
visitedFragmentNames [ fragmentName] = true
558
-
556
+
559
557
guard let fragment = exeContext. fragments [ fragmentName] else {
560
558
continue
561
559
}
562
-
560
+
563
561
let fragmentConditionMatches = try doesFragmentConditionMatch (
564
562
exeContext: exeContext,
565
563
fragment: fragment,
566
564
type: runtimeType
567
565
)
568
-
566
+
569
567
guard fragmentConditionMatches else {
570
568
continue
571
569
}
572
-
570
+
573
571
try collectFields (
574
572
exeContext: exeContext,
575
573
runtimeType: runtimeType,
576
574
selectionSet: fragment. selectionSet,
577
575
fields: & fields,
578
576
visitedFragmentNames: & visitedFragmentNames
579
577
)
580
- default :
581
- break
582
578
}
583
579
}
584
580
@@ -629,7 +625,7 @@ func doesFragmentConditionMatch(
629
625
return true
630
626
}
631
627
632
- guard let conditionalType = typeFromAST ( schema: exeContext. schema, inputTypeAST: typeConditionAST) else {
628
+ guard let conditionalType = typeFromAST ( schema: exeContext. schema, inputTypeAST: . namedType ( typeConditionAST) ) else {
633
629
return true
634
630
}
635
631
0 commit comments