@@ -4,7 +4,7 @@ import NIO
4
4
/**
5
5
* These are all of the possible kinds of types.
6
6
*/
7
- public protocol GraphQLType : CustomDebugStringConvertible , Encodable , KeySubscriptable { }
7
+ public protocol GraphQLType : CustomDebugStringConvertible , Encodable , KeySubscriptable , AnyObject , Equatable { }
8
8
extension GraphQLScalarType : GraphQLType { }
9
9
extension GraphQLObjectType : GraphQLType { }
10
10
extension GraphQLInterfaceType : GraphQLType { }
@@ -14,6 +14,12 @@ extension GraphQLInputObjectType : GraphQLType {}
14
14
extension GraphQLList : GraphQLType { }
15
15
extension GraphQLNonNull : GraphQLType { }
16
16
17
+ extension GraphQLType {
18
+ public static func == ( lhs: Self , rhs: Self ) -> Bool {
19
+ ObjectIdentifier ( lhs) == ObjectIdentifier ( rhs)
20
+ }
21
+ }
22
+
17
23
/**
18
24
* These types may be used as input types for arguments and directives.
19
25
*/
@@ -27,9 +33,9 @@ extension GraphQLNonNull : GraphQLInputType {}
27
33
//extension GraphQLList : GraphQLInputType where Element : GraphQLInputType {}
28
34
//extension GraphQLNonNull : GraphQLInputType where Element : (GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList<GraphQLInputType>) {}
29
35
30
- func isInputType( type: GraphQLType ? ) -> Bool {
36
+ func isInputType( type: ( any GraphQLType ) ? ) -> Bool {
31
37
let namedType = getNamedType ( type: type)
32
- return namedType is GraphQLInputType
38
+ return namedType is any GraphQLInputType
33
39
}
34
40
35
41
/**
@@ -59,7 +65,7 @@ public protocol GraphQLLeafType : GraphQLNamedType {
59
65
extension GraphQLScalarType : GraphQLLeafType { }
60
66
extension GraphQLEnumType : GraphQLLeafType { }
61
67
62
- func isLeafType( type: GraphQLType ? ) -> Bool {
68
+ func isLeafType( type: ( any GraphQLType ) ? ) -> Bool {
63
69
let namedType = getNamedType ( type: type)
64
70
return namedType is GraphQLScalarType ||
65
71
namedType is GraphQLEnumType
@@ -103,12 +109,12 @@ extension GraphQLEnumType : GraphQLNullableType {}
103
109
extension GraphQLInputObjectType : GraphQLNullableType { }
104
110
extension GraphQLList : GraphQLNullableType { }
105
111
106
- func getNullableType( type: GraphQLType ? ) -> GraphQLNullableType ? {
112
+ func getNullableType( type: ( any GraphQLType ) ? ) -> ( any GraphQLNullableType ) ? {
107
113
if let type = type as? GraphQLNonNull {
108
114
return type. ofType
109
115
}
110
116
111
- return type as? GraphQLNullableType
117
+ return type as? any GraphQLNullableType
112
118
}
113
119
114
120
/**
@@ -125,21 +131,21 @@ extension GraphQLUnionType : GraphQLNamedType {}
125
131
extension GraphQLEnumType : GraphQLNamedType { }
126
132
extension GraphQLInputObjectType : GraphQLNamedType { }
127
133
128
- public func getNamedType( type: GraphQLType ? ) -> GraphQLNamedType ? {
134
+ public func getNamedType( type: ( any GraphQLType ) ? ) -> ( any GraphQLNamedType ) ? {
129
135
var unmodifiedType = type
130
136
131
- while let type = unmodifiedType as? GraphQLWrapperType {
137
+ while let type = unmodifiedType as? ( any GraphQLWrapperType ) {
132
138
unmodifiedType = type. wrappedType
133
139
}
134
140
135
- return unmodifiedType as? GraphQLNamedType
141
+ return unmodifiedType as? ( any GraphQLNamedType )
136
142
}
137
143
138
144
/**
139
145
* These types wrap other types.
140
146
*/
141
147
protocol GraphQLWrapperType : GraphQLType {
142
- var wrappedType : GraphQLType { get }
148
+ var wrappedType : any GraphQLType { get }
143
149
}
144
150
145
151
extension GraphQLList : GraphQLWrapperType { }
@@ -536,8 +542,8 @@ public typealias GraphQLFieldResolveInput = (
536
542
public struct GraphQLResolveInfo {
537
543
public let fieldName : String
538
544
public let fieldASTs : [ Field ]
539
- public let returnType : GraphQLOutputType
540
- public let parentType : GraphQLCompositeType
545
+ public let returnType : any GraphQLOutputType
546
+ public let parentType : any GraphQLCompositeType
541
547
public let path : IndexPath
542
548
public let schema : GraphQLSchema
543
549
public let fragments : [ String : FragmentDefinition ]
@@ -549,15 +555,15 @@ public struct GraphQLResolveInfo {
549
555
public typealias GraphQLFieldMap = [ String : GraphQLField ]
550
556
551
557
public struct GraphQLField {
552
- public let type : GraphQLOutputType
558
+ public let type : any GraphQLOutputType
553
559
public let args : GraphQLArgumentConfigMap
554
560
public let deprecationReason : String ?
555
561
public let description : String ?
556
562
public let resolve : GraphQLFieldResolve ?
557
563
public let subscribe : GraphQLFieldResolve ?
558
564
559
565
public init (
560
- type: GraphQLOutputType ,
566
+ type: any GraphQLOutputType ,
561
567
description: String ? = nil ,
562
568
deprecationReason: String ? = nil ,
563
569
args: GraphQLArgumentConfigMap = [ : ]
@@ -571,7 +577,7 @@ public struct GraphQLField {
571
577
}
572
578
573
579
public init (
574
- type: GraphQLOutputType ,
580
+ type: any GraphQLOutputType ,
575
581
description: String ? = nil ,
576
582
deprecationReason: String ? = nil ,
577
583
args: GraphQLArgumentConfigMap = [ : ] ,
@@ -587,7 +593,7 @@ public struct GraphQLField {
587
593
}
588
594
589
595
public init (
590
- type: GraphQLOutputType ,
596
+ type: any GraphQLOutputType ,
591
597
description: String ? = nil ,
592
598
deprecationReason: String ? = nil ,
593
599
args: GraphQLArgumentConfigMap = [ : ] ,
@@ -611,7 +617,7 @@ public typealias GraphQLFieldDefinitionMap = [String: GraphQLFieldDefinition]
611
617
public final class GraphQLFieldDefinition {
612
618
public let name : String
613
619
public let description : String ?
614
- public internal( set) var type : GraphQLOutputType
620
+ public internal( set) var type : any GraphQLOutputType
615
621
public let args : [ GraphQLArgumentDefinition ]
616
622
public let resolve : GraphQLFieldResolve ?
617
623
public let subscribe : GraphQLFieldResolve ?
@@ -620,7 +626,7 @@ public final class GraphQLFieldDefinition {
620
626
621
627
init (
622
628
name: String ,
623
- type: GraphQLOutputType ,
629
+ type: any GraphQLOutputType ,
624
630
description: String ? = nil ,
625
631
deprecationReason: String ? = nil ,
626
632
args: [ GraphQLArgumentDefinition ] = [ ] ,
@@ -640,7 +646,7 @@ public final class GraphQLFieldDefinition {
640
646
func replaceTypeReferences( typeMap: TypeMap ) throws {
641
647
let resolvedType = try resolveTypeReference ( type: type, typeMap: typeMap)
642
648
643
- guard let outputType = resolvedType as? GraphQLOutputType else {
649
+ guard let outputType = resolvedType as? ( any GraphQLOutputType ) else {
644
650
throw GraphQLError (
645
651
message: " Resolved type \" \( resolvedType) \" is not a valid output type. "
646
652
)
@@ -695,12 +701,12 @@ extension GraphQLFieldDefinition : KeySubscriptable {
695
701
public typealias GraphQLArgumentConfigMap = [ String : GraphQLArgument ]
696
702
697
703
public struct GraphQLArgument {
698
- public let type : GraphQLInputType
704
+ public let type : any GraphQLInputType
699
705
public let description : String ?
700
706
public let defaultValue : Map ?
701
707
702
708
public init (
703
- type: GraphQLInputType ,
709
+ type: any GraphQLInputType ,
704
710
description: String ? = nil ,
705
711
defaultValue: Map ? = nil
706
712
) {
@@ -712,13 +718,13 @@ public struct GraphQLArgument {
712
718
713
719
public struct GraphQLArgumentDefinition {
714
720
public let name : String
715
- public let type : GraphQLInputType
721
+ public let type : any GraphQLInputType
716
722
public let defaultValue : Map ?
717
723
public let description : String ?
718
724
719
725
init (
720
726
name: String ,
721
- type: GraphQLInputType ,
727
+ type: any GraphQLInputType ,
722
728
defaultValue: Map ? = nil ,
723
729
description: String ? = nil
724
730
) {
@@ -1365,11 +1371,11 @@ func defineInputObjectFieldMap(
1365
1371
}
1366
1372
1367
1373
public struct InputObjectField {
1368
- public let type : GraphQLInputType
1374
+ public let type : any GraphQLInputType
1369
1375
public let defaultValue : Map ?
1370
1376
public let description : String ?
1371
1377
1372
- public init ( type: GraphQLInputType , defaultValue: Map ? = nil , description: String ? = nil ) {
1378
+ public init ( type: any GraphQLInputType , defaultValue: Map ? = nil , description: String ? = nil ) {
1373
1379
self . type = type
1374
1380
self . defaultValue = defaultValue
1375
1381
self . description = description
@@ -1380,13 +1386,13 @@ public typealias InputObjectFieldMap = [String: InputObjectField]
1380
1386
1381
1387
public final class InputObjectFieldDefinition {
1382
1388
public let name : String
1383
- public internal( set) var type : GraphQLInputType
1389
+ public internal( set) var type : any GraphQLInputType
1384
1390
public let description : String ?
1385
1391
public let defaultValue : Map ?
1386
1392
1387
1393
init (
1388
1394
name: String ,
1389
- type: GraphQLInputType ,
1395
+ type: any GraphQLInputType ,
1390
1396
description: String ? = nil ,
1391
1397
defaultValue: Map ? = nil
1392
1398
) {
@@ -1399,7 +1405,7 @@ public final class InputObjectFieldDefinition {
1399
1405
func replaceTypeReferences( typeMap: TypeMap ) throws {
1400
1406
let resolvedType = try resolveTypeReference ( type: type, typeMap: typeMap)
1401
1407
1402
- guard let inputType = resolvedType as? GraphQLInputType else {
1408
+ guard let inputType = resolvedType as? ( any GraphQLInputType ) else {
1403
1409
throw GraphQLError (
1404
1410
message: " Resolved type \" \( resolvedType) \" is not a valid input type. "
1405
1411
)
@@ -1464,18 +1470,18 @@ public typealias InputObjectFieldDefinitionMap = [String: InputObjectFieldDefini
1464
1470
*
1465
1471
*/
1466
1472
public final class GraphQLList {
1467
- public let ofType : GraphQLType
1473
+ public let ofType : any GraphQLType
1468
1474
public let kind : TypeKind = . list
1469
1475
1470
- public init ( _ type: GraphQLType ) {
1476
+ public init ( _ type: any GraphQLType ) {
1471
1477
self . ofType = type
1472
1478
}
1473
1479
1474
1480
public init ( _ name: String ) {
1475
1481
self . ofType = GraphQLTypeReference ( name)
1476
1482
}
1477
1483
1478
- var wrappedType : GraphQLType {
1484
+ var wrappedType : any GraphQLType {
1479
1485
return ofType
1480
1486
}
1481
1487
@@ -1548,25 +1554,25 @@ extension GraphQLList : Hashable {
1548
1554
* Note: the enforcement of non-nullability occurs within the executor.
1549
1555
*/
1550
1556
public final class GraphQLNonNull {
1551
- public let ofType : GraphQLNullableType
1557
+ public let ofType : any GraphQLNullableType
1552
1558
public let kind : TypeKind = . nonNull
1553
1559
1554
- public init ( _ type: GraphQLNullableType ) {
1560
+ public init ( _ type: any GraphQLNullableType ) {
1555
1561
self . ofType = type
1556
1562
}
1557
1563
1558
1564
public init ( _ name: String ) {
1559
1565
self . ofType = GraphQLTypeReference ( name)
1560
1566
}
1561
1567
1562
- var wrappedType : GraphQLType {
1568
+ var wrappedType : any GraphQLType {
1563
1569
return ofType
1564
1570
}
1565
1571
1566
1572
func replaceTypeReferences( typeMap: TypeMap ) throws -> GraphQLNonNull {
1567
1573
let resolvedType = try resolveTypeReference ( type: ofType, typeMap: typeMap)
1568
1574
1569
- guard let nullableType = resolvedType as? GraphQLNullableType else {
1575
+ guard let nullableType = resolvedType as? ( any GraphQLNullableType ) else {
1570
1576
throw GraphQLError (
1571
1577
message: " Resolved type \" \( resolvedType) \" is not a valid nullable type. "
1572
1578
)
0 commit comments