Skip to content

Commit f494988

Browse files
feat: Adds specifiedBy scalar directive
1 parent edcba6e commit f494988

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sources/Graphiti/Scalar/Scalar.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import OrderedCollections
99
/// you may provide your own serialize, parseValue, and parseLiteral implementations.
1010
open class Scalar<Resolver, Context, ScalarType: Codable>: TypeComponent<Resolver, Context> {
1111
// TODO: Change this no longer be an open class
12+
let specifiedByURL: String?
1213

1314
override func update(typeProvider: SchemaTypeProvider, coders: Coders) throws {
1415
let scalarType = try GraphQLScalarType(
1516
name: name,
1617
description: description,
18+
specifiedByURL: specifiedByURL,
1719
serialize: { value in
1820
if let serialize = self.serialize {
1921
return try serialize(value, coders)
@@ -70,10 +72,12 @@ open class Scalar<Resolver, Context, ScalarType: Codable>: TypeComponent<Resolve
7072
init(
7173
type _: ScalarType.Type,
7274
name: String?,
75+
specifiedBy: String? = nil,
7376
serialize: ((Any, Coders) throws -> Map)? = nil,
7477
parseValue: ((Map, Coders) throws -> Map)? = nil,
7578
parseLiteral: ((GraphQL.Value, Coders) throws -> Map)? = nil
7679
) {
80+
specifiedByURL = specifiedBy
7781
self.serialize = serialize
7882
self.parseValue = parseValue
7983
self.parseLiteral = parseLiteral
@@ -88,13 +92,15 @@ public extension Scalar {
8892
convenience init(
8993
_ type: ScalarType.Type,
9094
as name: String? = nil,
95+
specifiedBy: String? = nil,
9196
serialize: ((Any, Coders) throws -> Map)? = nil,
9297
parseValue: ((Map, Coders) throws -> Map)? = nil,
9398
parseLiteral: ((GraphQL.Value, Coders) throws -> Map)? = nil
9499
) {
95100
self.init(
96101
type: type,
97102
name: name,
103+
specifiedBy: specifiedBy,
98104
serialize: serialize,
99105
parseValue: parseValue,
100106
parseLiteral: parseLiteral

0 commit comments

Comments
 (0)