Skip to content

Commit c717399

Browse files
committed
Add support of Scalar aliases
1 parent de54332 commit c717399

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
@@ -233,6 +233,30 @@ as `4`) input value should be coerced to ID as appropriate for the ID formats
233233
a given GraphQL server expects. Any other input value, including float input
234234
values (such as `4.0`), must raise a query error indicating an incorrect type.
235235

236+
### Scalar aliases
237+
238+
Scalar aliases should be used to add specific semantic or validation on top
239+
of the existing scalar type.
240+
241+
Note: only scalar types can be aliassed, not other aliases.
242+
243+
For example, a type `DateTime` could be described as:
244+
245+
```
246+
scalar alias DateTime = String
247+
```
248+
249+
Where `DateTime` is the name of alias and `String` is the name of the base scalar type.
250+
251+
**Result Coercion**
252+
253+
Coertion of the scalar alias value should include coertion of base type as the
254+
last step.
255+
256+
**Input Coercion**
257+
258+
Coertion of the scalar alias value should include coertion of base type as the
259+
first step.
236260

237261
### Objects
238262

spec/Section 4 -- Introspection.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ type __Type {
146146
# INPUT_OBJECT only
147147
inputFields: [__InputValue!]
148148
149-
# NON_NULL and LIST only
149+
# SCALAR, NON_NULL and LIST only
150150
ofType: __Type
151151
}
152152
@@ -231,7 +231,8 @@ actually valid. These kinds are listed in the `__TypeKind` enumeration.
231231

232232
#### Scalar
233233

234-
Represents scalar types such as Int, String, and Boolean. Scalars cannot have fields.
234+
Represents scalar types such as Int, String, and Boolean or scalar aliases.
235+
Scalars cannot have fields.
235236

236237
A GraphQL type designer should describe the data format and scalar coercion
237238
rules in the description field of any scalar.
@@ -241,6 +242,7 @@ Fields
241242
* `kind` must return `__TypeKind.SCALAR`.
242243
* `name` must return a String.
243244
* `description` may return a String or {null}.
245+
* `ofType`: must return a base scalar type if alias or {null}.
244246
* All other fields must return {null}.
245247

246248

0 commit comments

Comments
 (0)