Skip to content

Commit edcfcba

Browse files
committed
Make GraphQLNamedType conform to Hashable
1 parent 3933850 commit edcfcba

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Sources/GraphQL/Type/Definition.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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, AnyObject, Equatable {}
7+
public protocol GraphQLType : CustomDebugStringConvertible, Encodable, KeySubscriptable, AnyObject {}
88
extension GraphQLScalarType : GraphQLType {}
99
extension GraphQLObjectType : GraphQLType {}
1010
extension GraphQLInterfaceType : GraphQLType {}
@@ -14,12 +14,6 @@ extension GraphQLInputObjectType : GraphQLType {}
1414
extension GraphQLList : GraphQLType {}
1515
extension GraphQLNonNull : GraphQLType {}
1616

17-
extension GraphQLType {
18-
public static func == (lhs: Self, rhs: Self) -> Bool {
19-
ObjectIdentifier(lhs) == ObjectIdentifier(rhs)
20-
}
21-
}
22-
2317
/**
2418
* These types may be used as input types for arguments and directives.
2519
*/
@@ -120,10 +114,20 @@ func getNullableType(type: (any GraphQLType)?) -> (any GraphQLNullableType)? {
120114
/**
121115
* These named types do not include modifiers like List or NonNull.
122116
*/
123-
public protocol GraphQLNamedType : GraphQLNullableType {
117+
public protocol GraphQLNamedType : GraphQLNullableType, Hashable {
124118
var name: String { get }
125119
}
126120

121+
extension GraphQLNamedType {
122+
public static func == (lhs: Self, rhs: Self) -> Bool {
123+
lhs.name == rhs.name
124+
}
125+
126+
public func hash(into hasher: inout Hasher) {
127+
name.hash(into: &hasher)
128+
}
129+
}
130+
127131
extension GraphQLScalarType : GraphQLNamedType {}
128132
extension GraphQLObjectType : GraphQLNamedType {}
129133
extension GraphQLInterfaceType : GraphQLNamedType {}

0 commit comments

Comments
 (0)