Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/popular-files-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

Ensure an error is thrown when `@stream` is detected and an `incrementalDelivery` handler is not configured.
8 changes: 4 additions & 4 deletions .size-limits.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 44753,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 39420,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 33901,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27727
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 44752,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 39500,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 33897,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27749
}
23 changes: 22 additions & 1 deletion src/__tests__/ApolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3052,7 +3052,28 @@ describe("ApolloClient", () => {

await expect(() => client.query({ query })).rejects.toThrow(
new InvariantError(
"`@defer` is not supported without specifying an incremental handler. Please pass a handler as the `incrementalHandler` option to the `ApolloClient` constructor."
"`@defer` and `@stream` are not supported without specifying an incremental handler. Please pass a handler as the `incrementalHandler` option to the `ApolloClient` constructor."
)
);
});

test("will error when used with `@stream` in a without specifying an incremental strategy", async () => {
const client = new ApolloClient({
cache: new InMemoryCache(),
link: ApolloLink.empty(),
});

const query = gql`
query {
items @stream {
bar
}
}
`;

await expect(() => client.query({ query })).rejects.toThrow(
new InvariantError(
"`@defer` and `@stream` are not supported without specifying an incremental handler. Please pass a handler as the `incrementalHandler` option to the `ApolloClient` constructor."
)
);
});
Expand Down
4 changes: 2 additions & 2 deletions src/incremental/handlers/notImplemented.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export class NotImplementedHandler implements Incremental.Handler<never> {
}
prepareRequest(request: ApolloLink.Request) {
invariant(
!hasDirectives(["defer"], request.query),
"`@defer` is not supported without specifying an incremental handler. Please pass a handler as the `incrementalHandler` option to the `ApolloClient` constructor."
!hasDirectives(["defer", "stream"], request.query),
"`@defer` and `@stream` are not supported without specifying an incremental handler. Please pass a handler as the `incrementalHandler` option to the `ApolloClient` constructor."
);

return request;
Expand Down