Skip to content

Commit 8a71abf

Browse files
committed
Add specifiedByURL to scalar types
1 parent f1d3e38 commit 8a71abf

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

Sources/GraphQL/Type/Definition.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ extension GraphQLNonNull : GraphQLWrapperType {}
165165
public final class GraphQLScalarType {
166166
public let name: String
167167
public let description: String?
168+
public let specifiedByURL: String?
168169
public let kind: TypeKind = .scalar
169170

170171
let serialize: (Any) throws -> Map
@@ -174,11 +175,13 @@ public final class GraphQLScalarType {
174175
public init(
175176
name: String,
176177
description: String? = nil,
178+
specifiedByURL: String? = nil,
177179
serialize: @escaping (Any) throws -> Map
178180
) throws {
179181
try assertValid(name: name)
180182
self.name = name
181183
self.description = description
184+
self.specifiedByURL = specifiedByURL
182185
self.serialize = serialize
183186
self.parseValue = nil
184187
self.parseLiteral = nil
@@ -187,13 +190,15 @@ public final class GraphQLScalarType {
187190
public init(
188191
name: String,
189192
description: String? = nil,
193+
specifiedByURL: String? = nil,
190194
serialize: @escaping (Any) throws -> Map,
191195
parseValue: @escaping (Map) throws -> Map,
192196
parseLiteral: @escaping (Value) throws -> Map
193197
) throws {
194198
try assertValid(name: name)
195199
self.name = name
196200
self.description = description
201+
self.specifiedByURL = specifiedByURL
197202
self.serialize = serialize
198203
self.parseValue = parseValue
199204
self.parseLiteral = parseLiteral

Sources/GraphQL/Type/Introspection.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,11 @@ let __DirectiveLocation = try! GraphQLEnumType(
179179

180180
let __Type: GraphQLObjectType = try! GraphQLObjectType(
181181
name: "__Type",
182-
description:
183-
"The fundamental unit of any GraphQL Schema is the type. There are " +
184-
"many kinds of types in GraphQL as represented by the `__TypeKind` enum." +
185-
"\n\nDepending on the kind of a type, certain fields describe " +
186-
"information about that type. Scalar types provide no information " +
187-
"beyond a name and description, while Enum types provide their values. " +
188-
"Object and Interface types provide the fields they describe. Abstract " +
189-
"types, Union and Interface, provide the Object types possible " +
190-
"at runtime. List and NonNull types compose other types.",
182+
description: """
183+
The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.
184+
185+
Depending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.
186+
""",
191187
fields: [
192188
"kind": GraphQLField(
193189
type: GraphQLNonNull(__TypeKind),
@@ -216,6 +212,7 @@ let __Type: GraphQLObjectType = try! GraphQLObjectType(
216212
),
217213
"name": GraphQLField(type: GraphQLString),
218214
"description": GraphQLField(type: GraphQLString),
215+
"specifiedByURL": GraphQLField(type: GraphQLString),
219216
"fields": GraphQLField(
220217
type: GraphQLList(GraphQLNonNull(__Field)),
221218
args: [

Sources/GraphQL/Utilities/BuildClientSchema.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public func buildClientSchema(introspection: IntrospectionQuery) throws -> Graph
9292
return try GraphQLScalarType(
9393
name: type.name,
9494
description: type.description,
95+
specifiedByURL: type.specifiedByURL,
9596
serialize: { try map(from: $0) }
9697
)
9798
case let type as IntrospectionObjectType:

Sources/GraphQL/Utilities/GetIntrospectionQuery.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
public func getIntrospectionQuery(
22
descriptions: Bool = true,
3-
specifiedByUrl: Bool = false,
3+
specifiedByURL: Bool = false,
44
directiveIsRepeatable: Bool = false,
55
schemaDescription: Bool = false,
66
inputValueDeprecation: Bool = false
77
) -> String {
88

99
let descriptions = descriptions ? "description" : ""
10-
let specifiedByUrl = specifiedByUrl ? "specifiedByURL" : ""
10+
let specifiedByURL = specifiedByURL ? "specifiedByURL" : ""
1111
let directiveIsRepeatable = directiveIsRepeatable ? "isRepeatable" : ""
1212
let schemaDescription = schemaDescription ? descriptions : ""
1313

@@ -40,7 +40,7 @@ public func getIntrospectionQuery(
4040
kind
4141
name
4242
\(descriptions)
43-
\(specifiedByUrl)
43+
\(specifiedByURL)
4444
fields(includeDeprecated: true) {
4545
name
4646
\(descriptions)

0 commit comments

Comments
 (0)