Skip to content

Commit 1c1fa22

Browse files
committed
First draft for upgrade guide
1 parent 05c92f4 commit 1c1fa22

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed
+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
title: Upgrading from v16 to v17
3+
sidebarTitle: v16 to v17
4+
---
5+
6+
import { Tabs } from 'nextra/components';
7+
8+
# Breaking changes
9+
10+
## Default values
11+
12+
Previously default-values were assumed to be coerced internal values, now
13+
we will treat them like a pre-coerced external input value. This equalises
14+
how we treat default-values in SDL and variables over JSON.
15+
16+
This goes hand-in-hand with the deprecation of `astFromValue` in favor of `valueToLiteral`.
17+
18+
## GraphQLError constructor arguments
19+
20+
The `GraphQLError` constructor now only accepts a message and options object as arguments. Previously, it also accepted positional arguments.
21+
22+
```diff
23+
- new GraphQLError('message', 'source', 'positions', 'path', 'originalError', 'extensions');
24+
+ new GraphQLError('message', { source, positions, path, originalError, extensions });
25+
```
26+
27+
## `createSourceEventStream` arguments
28+
29+
The `createSourceEventStream` function now only accepts an object as an argument. Previously, it also accepted positional arguments.
30+
31+
```diff
32+
- createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName);
33+
+ createSourceEventStream({ schema, document, rootValue, contextValue, variableValues, operationName });
34+
```
35+
36+
## `execute` will error for incremental delivery
37+
38+
The `execute` function will now throw an error if it sees a `@defer` or `@stream` directive. Use `experimentalExecuteIncrementally` instead.
39+
If you know you are dealing with incremental delivery requests, you can replace the import.
40+
41+
```diff
42+
- import { execute } from 'graphql';
43+
+ import { experimentalExecuteIncrementally as execute } from 'graphql';
44+
```
45+
46+
## Remove incremental delivery support from `subscribe`
47+
48+
In case you have fragments that you use with `defer/stream` that end up in a subscription,
49+
use the `if` argument of the directive to disable it in your subscription operation
50+
51+
## `subscribe` return type
52+
53+
The `subscribe` function can now also return a non-Promise value, previously this was only a Promise.
54+
This shouldn't change a lot as `await value` will still work as expected. This could lead to
55+
some typing inconsistencies though.
56+
57+
## Remove `singleResult` from incremental results
58+
59+
You can remove branches that check for `singleResult` in your code, as it is no longer used.
60+
61+
## Node support
62+
63+
Dropped support for Node 14 (subject to change)
64+
65+
## Removed `TokenKindEnum`, `KindEnum` and `DirectiveLocationEnum` types
66+
67+
We have removed the `TokenKindEnum`, `KindEnum` and `DirectiveLocationEnum` types,
68+
use `Kind`, `TokenKind` and `DirectiveLocation` instead. https://github.com/graphql/graphql-js/pull/3579
69+
70+
## Removed `graphql/subscription` module
71+
72+
use `graphql/execution` instead for subscriptions, all execution related exports have been
73+
unified there.
74+
75+
## Removed `GraphQLInterfaceTypeNormalizedConfig` export
76+
77+
Use `ReturnType<GraphQLInterfaceType['toConfig']>` if you really need this
78+
79+
## Empty AST collections will be undefined
80+
81+
Empty AST collections will be presented by `undefined` rather than an empty array.
82+
83+
## `Info.variableValues`
84+
85+
The shape of `Info.variableValues` has changed to be an object containing
86+
`sources` and `coerced` as keys.
87+
88+
A Source contains the `signature` and provided `value` pre-coercion for the
89+
variable. A `signature` is an object containing the `name`, `input-type` and
90+
`defaultValue` for the variable.
91+
92+
## Removals
93+
94+
- Removed exported `getOperationType` function
95+
- Removed exported `getVisitFn` function
96+
- Removed exported `printError` and `formatError` utilities
97+
- Removed exported `assertValidName` and `isValidNameError` utilities
98+
- Removed exported `assertValidExecutionArguments` function
99+
- Removed `getFieldDefFn` from `TypeInfo`
100+
- Removed `TypeInfo` from `validate` https://github.com/graphql/graphql-js/pull/4187
101+
102+
## Deprecations
103+
104+
- Deprecated `astFromValue` use `valueToLiteral` instead, when leveraging `valueToLiteral` ensure
105+
that you are working with externally provided values i.e. the SDL provided defaultValue to a variable.
106+
- Deprecated `valueFormAST` use `coerceInputLiteral` instead
107+
108+
## New Features
109+
110+
- Added `hideSuggestions` option to `execute`/`validate`/`subscribe`/... to hide schema-suggestions in error messages
111+
- Added `abortSignal` option to `graphql()`, `execute()`, and `subscribe()` allows cancellation of these methods;
112+
the `abortSignal` can also be passed to field resolvers to cancel asynchronous work that they initiate.
113+
- `extensions` support `symbol` keys, in addition to the normal string keys.
114+
115+
## New Experimental Features
116+
117+
### Experimental Support for Incremental Delivery
118+
119+
- [Spec PR](https://github.com/graphql/graphql-spec/pull/1110) / [RFC](https://github.com/graphql/graphql-wg/blob/main/rfcs/DeferStream.md)
120+
- enabled only when using `experimentalExecuteIncrementally()`, use of a schema or operation with `@defer`/`@stream` directives within `execute()` will now throw.
121+
- enable early execution with the new `enableEarlyExecution` configuration option for `experimentalExecuteIncrementally()`.
122+
123+
### Experimental Support for Fragment Arguments
124+
125+
- [Spec PR](https://github.com/graphql/graphql-spec/pull/1081)
126+
- enable with the new `experimentalFragmentArguments` configuration option for `parse()`.
127+
- new experimental `Kind.FRAGMENT_ARGUMENT` for visiting
128+
- new experimental `TypeInfo` methods and options for handling fragment arguments.
129+
- coerce AST via new function `coerceInputLiteral()` with experimental fragment variables argument (as opposed to deprecated `valueFromAST()` function).

0 commit comments

Comments
 (0)