Skip to content

Commit

Permalink
Merge branch 'main' into release-4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller authored Jan 22, 2025
2 parents 400e4e9 + bf313a3 commit af3a90a
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-singers-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

Remove unused dependency `response-iterator`
5 changes: 5 additions & 0 deletions .changeset/ten-rules-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

Fixes an issue where `client.watchFragment`/`useFragment` with `@includes` crashes when a separate cache update writes to the conditionally included fields.
12 changes: 7 additions & 5 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🔮 Apollo Client Ecosystem Roadmap

**Last updated: 2025-01-08**
**Last updated: 2025-01-22**

For up to date release notes, refer to the project's [Changelog](https://github.com/apollographql/apollo-client/blob/main/CHANGELOG.md).

Expand All @@ -17,8 +17,8 @@ For up to date release notes, refer to the project's [Changelog](https://github.

### Apollo Client

#### 3.13.0 - January 13, 2024
_Release candidate - January 7th_
#### 3.13.0 - February 3, 2024
_Release candidate - January 27th_

- `useSuspenseFragment`

Expand Down Expand Up @@ -47,11 +47,13 @@ _No outstanding work_

### Apollo Client DevTools

- Memory panel

_These changes will take longer than anticipated due to prioritization on Apollo Client 4.0_

### Apollo Client React Framework Integrations

- New/more robust documentation
- Support for `@defer` in RSC
- Support for `@defer` with `PreloadQuery`
- Support for Apollo Client Streaming in TanStack Router
- Support for Apollo Client Streaming in React Router 7
- Support for Apollo Client Streaming in React Router 7 (merged)
9 changes: 0 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
"graphql-tag": "^2.12.6",
"optimism": "^0.18.0",
"rehackt": "^0.1.0",
"response-iterator": "^0.2.6",
"symbol-observable": "^4.0.0",
"ts-invariant": "^0.10.3",
"tslib": "^2.3.0",
Expand Down
69 changes: 69 additions & 0 deletions src/__tests__/ApolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2465,6 +2465,75 @@ describe("ApolloClient", () => {
}
});

it("supports the @includes directive with `variables` - parallel cache modification", async () => {
const cache = new InMemoryCache();
const client = new ApolloClient({ cache });

const FullFragment = gql`
fragment ItemFragment on Item {
id
text
}
`;

const ItemFragment = gql`
fragment ItemFragment on Item {
id
...IncludedFragment @include(if: $withText)
}
fragment IncludedFragment on Item {
id
text
}
`;

cache.writeFragment({
fragment: FullFragment,
data: {
__typename: "Item",
id: 5,
text: "Item #5",
},
});

const observable = client.watchFragment({
fragment: ItemFragment,
from: { __typename: "Item", id: 5 },
variables: { withText: true },
fragmentName: "ItemFragment",
});

const stream = new ObservableStream(observable);

await expect(stream).toEmitValueStrict({
data: {
__typename: "Item",
id: 5,
text: "Item #5",
},
complete: true,
});

client.writeFragment({
fragment: FullFragment,
data: {
__typename: "Item",
id: 5,
text: "changed Item #5",
},
});

await expect(stream).toEmitValueStrict({
data: {
__typename: "Item",
id: 5,
text: "changed Item #5",
},
complete: true,
});
});

it("works with nested fragments", async () => {
const cache = new InMemoryCache();
const client = new ApolloClient({
Expand Down
9 changes: 8 additions & 1 deletion src/cache/core/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,14 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
if (
// Always ensure we deliver the first result
latestDiff &&
equalByQuery(query, { data: latestDiff?.result }, { data })
equalByQuery(
query,
{ data: latestDiff.result },
{ data },
// TODO: Fix the type on WatchFragmentOptions so that TVars
// extends OperationVariables
options.variables as OperationVariables
)
) {
return;
}
Expand Down

0 comments on commit af3a90a

Please sign in to comment.