Skip to content

Commit

Permalink
feat: send multipart/mixed in accept header for multipart-subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
alessbell committed Mar 17, 2023
1 parent 364bee9 commit 84b3a65
Show file tree
Hide file tree
Showing 8 changed files with 487 additions and 207 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-tomatoes-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

Adds support for multipart subscriptions in `HTTPLink`.
3 changes: 1 addition & 2 deletions config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ const react18TestFileIgnoreList = [
// to avoid running them twice with both react versions
// since they do not import react
ignoreTSFiles,
// failing hoc tests (8)
// failing hoc tests (7)
'src/react/hoc/__tests__/mutations/queries.test.tsx',
'src/react/hoc/__tests__/mutations/recycled-queries.test.tsx',
'src/react/hoc/__tests__/queries/errors.test.tsx',
'src/react/hoc/__tests__/queries/lifecycle.test.tsx',
'src/react/hoc/__tests__/queries/loading.test.tsx',
'src/react/hoc/__tests__/queries/observableQuery.test.tsx',
'src/react/hoc/__tests__/queries/skip.test.tsx',
'src/react/hoc/__tests__/subscriptions/subscriptions.test.tsx',
// failing components tests (1)
'src/react/components/__tests__/client/Query.test.tsx',
];
Expand Down
26 changes: 21 additions & 5 deletions src/link/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ export interface ExecutionPatchInitialResult<
extensions?: TExtensions;
}

export interface IncrementalPayload<
TData,
TExtensions,
> {
export interface IncrementalPayload<TData, TExtensions> {
// data and path must both be present
// https://github.com/graphql/graphql-spec/pull/742/files#diff-98d0cd153b72b63c417ad4238e8cc0d3385691ccbde7f7674bc0d2a718b896ecR288-R293
data: TData | null;
Expand All @@ -48,6 +45,24 @@ export interface ExecutionPatchIncrementalResult<
extensions?: never;
}

export interface ExecutionPayloadPatchResult<
TData = Record<string, any>,
TExtensions = Record<string, any>
> {
payload: SingleExecutionResult | ExecutionPatchResult;
// Data is never present at the top level here, but a significant refactoring
// would be needed to omit it here, since FetchResult assumes at least an
// optional data key.
data?: never;
// Transport layer errors (as distinct from GraphQL or NetworkErrors),
// these are fatal errors that will include done: true.
// TODO: is GraphQLError[] appropriate here?
errors?: ReadonlyArray<GraphQLError>;
// Done can be true or false and is present as `done: true` on the final
// chunk, or when fatal errors occur.
done?: boolean;
}

export type ExecutionPatchResult<
TData = Record<string, any>,
TExtensions = Record<string, any>
Expand Down Expand Up @@ -87,7 +102,8 @@ export type FetchResult<
TExtensions = Record<string, any>
> =
| SingleExecutionResult<TData, TContext, TExtensions>
| ExecutionPatchResult<TData, TExtensions>;
| ExecutionPatchResult<TData, TExtensions>
| ExecutionPayloadPatchResult<TData, TExtensions>;

export type NextLink = (operation: Operation) => Observable<FetchResult>;

Expand Down
Loading

0 comments on commit 84b3a65

Please sign in to comment.