File tree 1 file changed +12
-3
lines changed 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -217,18 +217,27 @@ type GraphQLScalarTypeConfig<InternalType> = {
217
217
` ` `
218
218
219
219
The leaf values of any request and input values to arguments are
220
- Scalars (or Enums) and are defined with a name and a series of coercion
220
+ Scalars (or Enums) and are defined with a name and a series of serialization
221
221
functions used to ensure validity.
222
222
223
223
#### Example
224
224
225
225
` ` ` js
226
226
var OddType = new GraphQLScalarType ({
227
227
name: ' Odd' ,
228
- coerce (value ) {
229
- return value % 2 === 1 ? value : null ;
228
+ serialize: oddValue,
229
+ parseValue: oddValue,
230
+ parseLiteral (ast ) {
231
+ if (ast .kind === Kind .INT ) {
232
+ return oddValue (parseInt (ast .value , 10 ));
233
+ }
234
+ return null ;
230
235
}
231
236
});
237
+
238
+ function oddValue (value ) {
239
+ return value % 2 === 1 ? value : null ;
240
+ }
232
241
` ` `
233
242
234
243
### GraphQLObjectType
You can’t perform that action at this time.
0 commit comments