Skip to content

Commit 3044621

Browse files
committed
Add support of Scalar aliases
1 parent b3d24b4 commit 3044621

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

spec/Section 3 -- Type System.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,30 @@ as `4`) input value should be coerced to ID as appropriate for the ID formats
247247
a given GraphQL server expects. Any other input value, including float input
248248
values (such as `4.0`), must raise a query error indicating an incorrect type.
249249

250+
### Scalar aliases
251+
252+
Scalar aliases should be used to add specific semantic or validation on top
253+
of the existing scalar type.
254+
255+
Note: only scalar types can be aliassed, not other aliases.
256+
257+
For example, a type `DateTime` could be described as:
258+
259+
```
260+
scalar alias DateTime = String
261+
```
262+
263+
Where `DateTime` is the name of alias and `String` is the name of the base scalar type.
264+
265+
**Result Coercion**
266+
267+
Coertion of the scalar alias value should include coertion of base type as the
268+
last step.
269+
270+
**Input Coercion**
271+
272+
Coertion of the scalar alias value should include coertion of base type as the
273+
first step.
250274

251275
### Objects
252276

spec/Section 4 -- Introspection.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ type __Type {
148148
# INPUT_OBJECT only
149149
inputFields: [__InputValue!]
150150
151-
# NON_NULL and LIST only
151+
# SCALAR, NON_NULL and LIST only
152152
ofType: __Type
153153
}
154154
@@ -234,7 +234,8 @@ actually valid. These kinds are listed in the `__TypeKind` enumeration.
234234

235235
#### Scalar
236236

237-
Represents scalar types such as Int, String, and Boolean. Scalars cannot have fields.
237+
Represents scalar types such as Int, String, and Boolean or scalar aliases.
238+
Scalars cannot have fields.
238239

239240
A GraphQL type designer should describe the data format and scalar coercion
240241
rules in the description field of any scalar.
@@ -244,6 +245,7 @@ Fields
244245
* `kind` must return `__TypeKind.SCALAR`.
245246
* `name` must return a String.
246247
* `description` may return a String or {null}.
248+
* `ofType`: must return a base scalar type if alias or {null}.
247249
* All other fields must return {null}.
248250

249251

0 commit comments

Comments
 (0)