Skip to content

Commit 4740447

Browse files
refactor!: Rename Scalar to GraphQLScalar
1 parent 969787c commit 4740447

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

Examples/HelloWorldServer/Sources/HelloWorldServer/Resolvers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class GraphQLContext: @unchecked Sendable {
2323
}
2424

2525
// Scalars must be represented by a Swift type of the same name, conforming to the Scalar protocol
26-
public struct EmailAddress: Scalar {
26+
public struct EmailAddress: GraphQLScalar {
2727
let email: String
2828

2929
init(email: String) {

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public actor GraphQLContext {
6868
}
6969
```
7070

71-
Create any scalar types (with names matching GraphQL), and conform them to `Scalar`. See the `Scalars` usage section below for details.
71+
Create any scalar types (with names matching GraphQL), and conform them to `GraphQLScalar`. See the `Scalars` usage section below for details.
7272

7373
Create a resolvers struct with the required typealiases:
7474
```swift
@@ -172,12 +172,12 @@ Input object types are modeled as a deterministic Codable struct with the declar
172172
Enum types are modeled as a deterministic String enum with values matching the declared fields and associated representations. If you need different values or more complex implementations, simply convert to/from a different representation inside your resolvers.
173173

174174
### Scalar Types
175-
Scalar types are not modeled by the generator. They are simply referenced using the Scalar's name, and you are expected to implement the required type. Since GraphQL uses a different serialization system than Swift, you must conform the type to Swift's `Codable` and GraphQL's `Scalar`, and have them agree on a representation.
175+
Scalar types are not modeled by the generator. They are simply referenced using the Scalar's name, and you are expected to implement the required type. Since GraphQL uses a different serialization system than Swift, you must conform the type to Swift's `Codable` and GraphQL's `GraphQLScalar`, and have them agree on a representation.
176176

177177
Below is an example that represents a scalar struct as a raw String:
178178

179179
```swift
180-
public struct EmailAddress: Scalar {
180+
public struct EmailAddress: GraphQLScalar {
181181
let email: String
182182

183183
init(email: String) {

Sources/GraphQLGeneratorRuntime/Scalar.swift renamed to Sources/GraphQLGeneratorRuntime/GraphQLScalar.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import GraphQL
22
import OrderedCollections
33

4-
public protocol Scalar: Sendable, Codable {
4+
public protocol GraphQLScalar: Sendable, Codable {
55
static func serialize(this: Self) throws -> Map
66
static func parseValue(map: Map) throws -> Map
77
static func parseLiteral(value: any Value) throws -> Map
@@ -11,7 +11,7 @@ public protocol Scalar: Sendable, Codable {
1111
// inefficient. They typically pass through a full serialize/deserialize step on each call.
1212
// Because of this, we have chosen not to vend defaults to force the user to implement more performant versions.
1313

14-
public extension Scalar {
14+
public extension GraphQLScalar {
1515
/// This wraps the GraphQLScalar definition in a type-safe one
1616
static func serialize(any: Any) throws -> Map {
1717
// We should always get a value of `Self` for custom scalars.

0 commit comments

Comments
 (0)