···11+---
22+'@urql/core': major
33+---
44+55+Update `subscriptionExchange` to receive `FetchBody` instead. In the usual usage of `subscriptionExchange` (for instance with `graphql-ws`) you can expect no breaking changes. However, the `key` and `extensions` field has been removed and instead the `forwardSubscription` function receives the full `Operation` as a second argument.
+5
.changeset/slow-glasses-attend.md
···11+---
22+'@urql/core': minor
33+---
44+55+Support `GraphQLRequest.extensions` as spec-extensions input to GraphQL requests.
···1111} from 'wonka';
12121313import {
1414- stringifyDocument,
1514 makeResult,
1515+ mergeResultPatch,
1616 makeErrorResult,
1717 makeOperation,
1818- mergeResultPatch,
1918} from '../utils';
20192120import {
2221 Exchange,
2322 ExecutionResult,
2423 Operation,
2525- OperationContext,
2624 OperationResult,
2725} from '../types';
2626+2727+import { FetchBody, makeFetchBody } from '../internal';
28282929/** An abstract observer-like interface.
3030 *
···6565 };
6666}
67676868-/** A more cross-compatible version of the {@link Operation} structure.
6969- *
7070- * @remarks
7171- * When the `subscriptionExchange` was first created, some transports needed a specific shape
7272- * of {@link GraphQLRequest} objects to be passed to them. This is a shim that is as compatible
7373- * with most transports out of the box as possible.
6868+/** A more cross-compatible version of the {@link GraphQLRequest} structure.
6969+ * {@link FetchBody} for more details
7470 */
7575-export interface SubscriptionOperation {
7676- query: string;
7777- variables: Record<string, unknown> | undefined;
7878- key: string;
7979- context: OperationContext;
8080-}
7171+export type SubscriptionOperation = FetchBody;
81728273/** A subscription forwarding function, which must accept a {@link SubscriptionOperation}.
8374 *
···8576 * @returns An {@link ObservableLike} object issuing {@link ExecutionResult | ExecutionResults}.
8677 */
8778export type SubscriptionForwarder = (
8888- operation: SubscriptionOperation
7979+ request: FetchBody,
8080+ operation: Operation
8981) => ObservableLike<ExecutionResult>;
90829183/** This is called to create a subscription and needs to be hooked up to a transport client. */
···148140 const createSubscriptionSource = (
149141 operation: Operation
150142 ): Source<OperationResult> => {
151151- // This excludes the query's name as a field although subscription-transport-ws does accept it since it's optional
152152- const observableish = forwardSubscription({
153153- key: operation.key.toString(36),
154154- query: stringifyDocument(operation.query),
155155- variables: operation.variables!,
156156- context: { ...operation.context },
157157- });
143143+ const observableish = forwardSubscription(
144144+ makeFetchBody(operation),
145145+ operation
146146+ );
158147159148 return make<OperationResult>(({ next, complete }) => {
160149 let isComplete = false;
···236236 * generic, are sent to the GraphQL API to execute a request.
237237 */
238238 variables: Variables;
239239+ /** Additional metadata that a GraphQL API may accept for spec extensions.
240240+ * @see {@link https://github.com/graphql/graphql-over-http/blob/1928447/spec/GraphQLOverHTTP.md#request-parameters} for the GraphQL over HTTP spec
241241+ */
242242+ extensions?: Record<string, any> | undefined;
239243}
240244241245/** Parameters from which {@link GraphQLRequest | GraphQLRequests} are created from.