You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defer/stream: split incremental delivery into new entry point
This PR changes the `execute` and `graphql` APIs on the `defer-stream`
branch back to having the same API as on `main`: they can only produce a
single `ExecutionResult` and do not support incremental delivery.
Incremental delivery is now provided by the new entry point
`experimentalExecuteIncrementally`. (We will remove "experimental" once
the proposal has been merged into the GraphQL spec.) This function
always returns a Promise containing an object that is *either* a single
result *or* an initial result plus a generator for subsequent results.
This will make upgrading to graphql@17 easier, and increases the clarity
of return types.
Use distinct types for "the only result of a single-payload execution",
"the first payload of a multi-payload execution", and "subsequent
payloads of a multi-payload execution", since the data structures are
different. (Multi-payload executions *always* have at least one payload,
and the structure differs, which is why the new types separate the
initial result from subsequent results.)
Note that with the previous types, you actually had to use a function
with a type guard like `isAsyncIterable`: you couldn't just write `if
(Symbol.asyncIterator in result)`. I think both explicitly separating
the first (differently-typed) element from the rest of the elements
*and* making it possible to differentiate the types with a simple `in`
check are improvements. Additionally, somebody using the API in
JavaScript who doesn't realize that there is new functionality available
who is confused that the result no longer has `data`/`errors` fields can
just print out the result and see and search for the terms
`initialResult` and `subsequentResults` instead of only seeing iterator
internals.
Fix `Formatted*Result` types to use `GraphQLFormattedError` rather than
`GraphQLError` for `errors` nested inside `incremental`.
0 commit comments