@@ -4,7 +4,7 @@ import NIO
44/**
55 * These are all of the possible kinds of types.
66 */
7- public protocol GraphQLType : CustomDebugStringConvertible , Encodable , KeySubscriptable { }
7+ public protocol GraphQLType : CustomDebugStringConvertible , Encodable , KeySubscriptable , AnyObject , Equatable { }
88extension GraphQLScalarType : GraphQLType { }
99extension GraphQLObjectType : GraphQLType { }
1010extension GraphQLInterfaceType : GraphQLType { }
@@ -14,6 +14,12 @@ extension GraphQLInputObjectType : GraphQLType {}
1414extension GraphQLList : GraphQLType { }
1515extension GraphQLNonNull : GraphQLType { }
1616
17+ extension GraphQLType {
18+ public static func == ( lhs: Self , rhs: Self ) -> Bool {
19+ ObjectIdentifier ( lhs) == ObjectIdentifier ( rhs)
20+ }
21+ }
22+
1723/**
1824 * These types may be used as input types for arguments and directives.
1925 */
@@ -27,9 +33,9 @@ extension GraphQLNonNull : GraphQLInputType {}
2733//extension GraphQLList : GraphQLInputType where Element : GraphQLInputType {}
2834//extension GraphQLNonNull : GraphQLInputType where Element : (GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType | GraphQLList<GraphQLInputType>) {}
2935
30- func isInputType( type: GraphQLType ? ) -> Bool {
36+ func isInputType( type: ( any GraphQLType ) ? ) -> Bool {
3137 let namedType = getNamedType ( type: type)
32- return namedType is GraphQLInputType
38+ return namedType is any GraphQLInputType
3339}
3440
3541/**
@@ -59,7 +65,7 @@ public protocol GraphQLLeafType : GraphQLNamedType {
5965extension GraphQLScalarType : GraphQLLeafType { }
6066extension GraphQLEnumType : GraphQLLeafType { }
6167
62- func isLeafType( type: GraphQLType ? ) -> Bool {
68+ func isLeafType( type: ( any GraphQLType ) ? ) -> Bool {
6369 let namedType = getNamedType ( type: type)
6470 return namedType is GraphQLScalarType ||
6571 namedType is GraphQLEnumType
@@ -103,12 +109,12 @@ extension GraphQLEnumType : GraphQLNullableType {}
103109extension GraphQLInputObjectType : GraphQLNullableType { }
104110extension GraphQLList : GraphQLNullableType { }
105111
106- func getNullableType( type: GraphQLType ? ) -> GraphQLNullableType ? {
112+ func getNullableType( type: ( any GraphQLType ) ? ) -> ( any GraphQLNullableType ) ? {
107113 if let type = type as? GraphQLNonNull {
108114 return type. ofType
109115 }
110116
111- return type as? GraphQLNullableType
117+ return type as? any GraphQLNullableType
112118}
113119
114120/**
@@ -125,21 +131,21 @@ extension GraphQLUnionType : GraphQLNamedType {}
125131extension GraphQLEnumType : GraphQLNamedType { }
126132extension GraphQLInputObjectType : GraphQLNamedType { }
127133
128- public func getNamedType( type: GraphQLType ? ) -> GraphQLNamedType ? {
134+ public func getNamedType( type: ( any GraphQLType ) ? ) -> ( any GraphQLNamedType ) ? {
129135 var unmodifiedType = type
130136
131- while let type = unmodifiedType as? GraphQLWrapperType {
137+ while let type = unmodifiedType as? ( any GraphQLWrapperType ) {
132138 unmodifiedType = type. wrappedType
133139 }
134140
135- return unmodifiedType as? GraphQLNamedType
141+ return unmodifiedType as? ( any GraphQLNamedType )
136142}
137143
138144/**
139145 * These types wrap other types.
140146 */
141147protocol GraphQLWrapperType : GraphQLType {
142- var wrappedType : GraphQLType { get }
148+ var wrappedType : any GraphQLType { get }
143149}
144150
145151extension GraphQLList : GraphQLWrapperType { }
@@ -536,8 +542,8 @@ public typealias GraphQLFieldResolveInput = (
536542public struct GraphQLResolveInfo {
537543 public let fieldName : String
538544 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
541547 public let path : IndexPath
542548 public let schema : GraphQLSchema
543549 public let fragments : [ String : FragmentDefinition ]
@@ -549,15 +555,15 @@ public struct GraphQLResolveInfo {
549555public typealias GraphQLFieldMap = [ String : GraphQLField ]
550556
551557public struct GraphQLField {
552- public let type : GraphQLOutputType
558+ public let type : any GraphQLOutputType
553559 public let args : GraphQLArgumentConfigMap
554560 public let deprecationReason : String ?
555561 public let description : String ?
556562 public let resolve : GraphQLFieldResolve ?
557563 public let subscribe : GraphQLFieldResolve ?
558564
559565 public init (
560- type: GraphQLOutputType ,
566+ type: any GraphQLOutputType ,
561567 description: String ? = nil ,
562568 deprecationReason: String ? = nil ,
563569 args: GraphQLArgumentConfigMap = [ : ]
@@ -571,7 +577,7 @@ public struct GraphQLField {
571577 }
572578
573579 public init (
574- type: GraphQLOutputType ,
580+ type: any GraphQLOutputType ,
575581 description: String ? = nil ,
576582 deprecationReason: String ? = nil ,
577583 args: GraphQLArgumentConfigMap = [ : ] ,
@@ -587,7 +593,7 @@ public struct GraphQLField {
587593 }
588594
589595 public init (
590- type: GraphQLOutputType ,
596+ type: any GraphQLOutputType ,
591597 description: String ? = nil ,
592598 deprecationReason: String ? = nil ,
593599 args: GraphQLArgumentConfigMap = [ : ] ,
@@ -611,7 +617,7 @@ public typealias GraphQLFieldDefinitionMap = [String: GraphQLFieldDefinition]
611617public final class GraphQLFieldDefinition {
612618 public let name : String
613619 public let description : String ?
614- public internal( set) var type : GraphQLOutputType
620+ public internal( set) var type : any GraphQLOutputType
615621 public let args : [ GraphQLArgumentDefinition ]
616622 public let resolve : GraphQLFieldResolve ?
617623 public let subscribe : GraphQLFieldResolve ?
@@ -620,7 +626,7 @@ public final class GraphQLFieldDefinition {
620626
621627 init (
622628 name: String ,
623- type: GraphQLOutputType ,
629+ type: any GraphQLOutputType ,
624630 description: String ? = nil ,
625631 deprecationReason: String ? = nil ,
626632 args: [ GraphQLArgumentDefinition ] = [ ] ,
@@ -640,7 +646,7 @@ public final class GraphQLFieldDefinition {
640646 func replaceTypeReferences( typeMap: TypeMap ) throws {
641647 let resolvedType = try resolveTypeReference ( type: type, typeMap: typeMap)
642648
643- guard let outputType = resolvedType as? GraphQLOutputType else {
649+ guard let outputType = resolvedType as? ( any GraphQLOutputType ) else {
644650 throw GraphQLError (
645651 message: " Resolved type \" \( resolvedType) \" is not a valid output type. "
646652 )
@@ -695,12 +701,12 @@ extension GraphQLFieldDefinition : KeySubscriptable {
695701public typealias GraphQLArgumentConfigMap = [ String : GraphQLArgument ]
696702
697703public struct GraphQLArgument {
698- public let type : GraphQLInputType
704+ public let type : any GraphQLInputType
699705 public let description : String ?
700706 public let defaultValue : Map ?
701707
702708 public init (
703- type: GraphQLInputType ,
709+ type: any GraphQLInputType ,
704710 description: String ? = nil ,
705711 defaultValue: Map ? = nil
706712 ) {
@@ -712,13 +718,13 @@ public struct GraphQLArgument {
712718
713719public struct GraphQLArgumentDefinition {
714720 public let name : String
715- public let type : GraphQLInputType
721+ public let type : any GraphQLInputType
716722 public let defaultValue : Map ?
717723 public let description : String ?
718724
719725 init (
720726 name: String ,
721- type: GraphQLInputType ,
727+ type: any GraphQLInputType ,
722728 defaultValue: Map ? = nil ,
723729 description: String ? = nil
724730 ) {
@@ -1365,11 +1371,11 @@ func defineInputObjectFieldMap(
13651371}
13661372
13671373public struct InputObjectField {
1368- public let type : GraphQLInputType
1374+ public let type : any GraphQLInputType
13691375 public let defaultValue : Map ?
13701376 public let description : String ?
13711377
1372- public init ( type: GraphQLInputType , defaultValue: Map ? = nil , description: String ? = nil ) {
1378+ public init ( type: any GraphQLInputType , defaultValue: Map ? = nil , description: String ? = nil ) {
13731379 self . type = type
13741380 self . defaultValue = defaultValue
13751381 self . description = description
@@ -1380,13 +1386,13 @@ public typealias InputObjectFieldMap = [String: InputObjectField]
13801386
13811387public final class InputObjectFieldDefinition {
13821388 public let name : String
1383- public internal( set) var type : GraphQLInputType
1389+ public internal( set) var type : any GraphQLInputType
13841390 public let description : String ?
13851391 public let defaultValue : Map ?
13861392
13871393 init (
13881394 name: String ,
1389- type: GraphQLInputType ,
1395+ type: any GraphQLInputType ,
13901396 description: String ? = nil ,
13911397 defaultValue: Map ? = nil
13921398 ) {
@@ -1399,7 +1405,7 @@ public final class InputObjectFieldDefinition {
13991405 func replaceTypeReferences( typeMap: TypeMap ) throws {
14001406 let resolvedType = try resolveTypeReference ( type: type, typeMap: typeMap)
14011407
1402- guard let inputType = resolvedType as? GraphQLInputType else {
1408+ guard let inputType = resolvedType as? ( any GraphQLInputType ) else {
14031409 throw GraphQLError (
14041410 message: " Resolved type \" \( resolvedType) \" is not a valid input type. "
14051411 )
@@ -1464,18 +1470,18 @@ public typealias InputObjectFieldDefinitionMap = [String: InputObjectFieldDefini
14641470 *
14651471 */
14661472public final class GraphQLList {
1467- public let ofType : GraphQLType
1473+ public let ofType : any GraphQLType
14681474 public let kind : TypeKind = . list
14691475
1470- public init ( _ type: GraphQLType ) {
1476+ public init ( _ type: any GraphQLType ) {
14711477 self . ofType = type
14721478 }
14731479
14741480 public init ( _ name: String ) {
14751481 self . ofType = GraphQLTypeReference ( name)
14761482 }
14771483
1478- var wrappedType : GraphQLType {
1484+ var wrappedType : any GraphQLType {
14791485 return ofType
14801486 }
14811487
@@ -1548,25 +1554,25 @@ extension GraphQLList : Hashable {
15481554 * Note: the enforcement of non-nullability occurs within the executor.
15491555 */
15501556public final class GraphQLNonNull {
1551- public let ofType : GraphQLNullableType
1557+ public let ofType : any GraphQLNullableType
15521558 public let kind : TypeKind = . nonNull
15531559
1554- public init ( _ type: GraphQLNullableType ) {
1560+ public init ( _ type: any GraphQLNullableType ) {
15551561 self . ofType = type
15561562 }
15571563
15581564 public init ( _ name: String ) {
15591565 self . ofType = GraphQLTypeReference ( name)
15601566 }
15611567
1562- var wrappedType : GraphQLType {
1568+ var wrappedType : any GraphQLType {
15631569 return ofType
15641570 }
15651571
15661572 func replaceTypeReferences( typeMap: TypeMap ) throws -> GraphQLNonNull {
15671573 let resolvedType = try resolveTypeReference ( type: ofType, typeMap: typeMap)
15681574
1569- guard let nullableType = resolvedType as? GraphQLNullableType else {
1575+ guard let nullableType = resolvedType as? ( any GraphQLNullableType ) else {
15701576 throw GraphQLError (
15711577 message: " Resolved type \" \( resolvedType) \" is not a valid nullable type. "
15721578 )
0 commit comments