Skip to content

Commit ccb0ea1

Browse files
committed
flesh out input coercion changes
1 parent 5ed0048 commit ccb0ea1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Diff for: website/docs/tutorials/whats-new-in-graphql-js-v17.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,32 @@
3333

3434
## New API features
3535

36-
- Use `coerceInputLiteral()` instead of `valueFromAST()`.
3736
- Support for resolver functions returning async iterables.
3837
- Expose `printDirective()` helper function.
3938

4039
## API Changes:
4140

41+
- Changes to input coercion:
42+
- Use new utility `coerceInputLiteral()` instead of `valueFromAST()`.
43+
- Use new utility `replaceVariableValues()` to replace variables within complex scalars uses as inputs. Internally, `replaceVariableValues()` uses new utility `valueToLiteral()` to convert from an external input value to a literal value. This allows variables embedded within complex scalars to use the correct default values.
44+
- Use new utility `valueToLiteral()` to convert from an external input value to a literal value. Custom scalars can define custom behavior by implementing an optional `valueToLiteral()` method.
45+
- Use new `parseConstLiteral()` methods on leaf types instead of `parseLiteral()` to convert literals to values, by first calling new utility `replaceVariableValues()` on the non-constant literal, and then by calling `parseConstLiteral()`.
4246
- Changes to the `subscribe()` function:
4347
- `subscribe()` may now return a non-promise.
4448
- When a subscription root field errors, `subscribe()` now returns a well-formatted `GraphQLError` rather than throwing.
49+
- Changes to Variable Values throughout the code base:
50+
- Variable Values are now a dedicated type containing both the coerced values as before as well as the variable signature and provided source, so that variables embedded within complex scalars will be able to be properly replaced. This is non-spec behavior, but was previously supported by `graphql-js` and will now be sound.
51+
- The return type of `getVariableValues()` has been updated, as have the provided arguments to `getArgumentValues()`, `coerceInputLiteral()`, and `collectFields()`, and `getDirectiveValues()`.
4552
- Changes to default values:
4653
- The `defaultValue` property of `GraphQLArgument` and `GraphQLInputField` is now of new type `GraphQLDefaultValueUsage`. A `GraphQLDefaultValueUsage` object contains either a `literal` property, which is as AST node representing the parsed default value included within the SDL, or a `value` property, the default value as specified programmatically.
4754
- Introspection now returns the exact original default value included within the SDL rather than attempting to "serialize" input values, avoiding some rare cases in which default values within an introspected schema could differ slightly from the original SDL (e.g. [#3501](https://github.com/graphql/graphql-js/issues/3051)).
4855
- Other Changes:
4956
- `IntrospectionType` is now properly typed using `TypeKind` Enum.
50-
- Changes to Variable Values throughout the code base:
51-
- Variable Values are now a dedicated type containing both the coerced values as before as well as the variable signature and provided source, so that variables embedded within complex scalars will be able to be properly replaced. This is non-spec behavior, but was previously supported by `graphql-js` and will now be sound.
52-
- The return type of `getVariableValues()` has been updated, as have the provided arguments to `getArgumentValues()`, `coerceInputLiteral()`, and `collectFields()`, and `getDirectiveValues()`.
5357

5458
## Deprecations
5559

5660
- `valueFromAST()` is deprecated, use `coerceInputLiteral()` instead.
61+
- `parseLiteral()` methods of custom scalars are deprecated, use `parseConstLiteral()` instead.
5762

5863
## Removals
5964

0 commit comments

Comments
 (0)