Skip to content

Commit

Permalink
Merge branch 'main' into release-3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller authored Nov 21, 2023
2 parents ebd8fe2 + bb17509 commit 0b3c308
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 73 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

Lint:
docker:
- image: cimg/node:21.1.0
- image: cimg/node:21.2.0
steps:
- checkout
- run: npm version
Expand All @@ -24,15 +24,15 @@ jobs:

Formatting:
docker:
- image: cimg/node:21.1.0
- image: cimg/node:21.2.0
steps:
- checkout
- run: npm ci
- run: npm run check:format

Tests:
docker:
- image: cimg/node:21.1.0
- image: cimg/node:21.2.0
steps:
- checkout
- run: npm run ci:precheck
Expand All @@ -50,7 +50,7 @@ jobs:

BuildTarball:
docker:
- image: cimg/node:21.1.0
- image: cimg/node:21.2.0
steps:
- checkout
- run: npm run ci:precheck
Expand All @@ -67,7 +67,7 @@ jobs:
framework:
type: string
docker:
- image: cimg/node:21.1.0
- image: cimg/node:21.2.0
steps:
- checkout
- attach_workspace:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
if: github.repository == 'apollographql/apollo-client'
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v4
- uses: dessant/lock-threads@v5
with:
github-token: ${{ github.token }}
log-output: true
Expand Down
6 changes: 3 additions & 3 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🔮 Apollo Client Roadmap

**Last updated: 2023-11-07**
**Last updated: 2023-11-21**

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

Expand All @@ -22,8 +22,8 @@ Tentative beta date: Dec 1, 2023
Features we plan to tackle:

- Ability to preload a query outside of a React component that can be used with `useReadQuery` to suspend while loading
- Introduce a new `useInteractiveQuery`/`useLazyBackgroundQuery` hook (name TBD)
- Improved testing utilities
- Introduce a new `useLoadableQuery` hook
- `<MockedProvider />` improvements
- Optimizing memory usage in SSR scenarios

> NOTE: These are subject to change and are not guaranteed to be part of 3.9 at the time of this writing.
Expand Down
2 changes: 2 additions & 0 deletions docs/source/data/mutations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ const [addTodo, { data, loading, error }] = useMutation(ADD_TODO, {
});
```

> You can only refetch _active_ queries. Active queries are those used by components on the current page. If the data you want to update is not fetched by a component on the current page, it's best to [update your cache directly](#updating-the-cache-directly).
Each element in the `refetchQueries` array is one of the following:

* A `DocumentNode` object parsed with the `gql` function
Expand Down
4 changes: 2 additions & 2 deletions docs/source/data/queries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function DogPhoto({ breed }) {
return (
<div>
<img src={data.dog.displayImage} style={{ height: 100, width: 100 }} />
<button onClick={() => refetch({ breed: 'new_dog_breed' })}>
<button onClick={() => refetch()}>
Refetch new breed!
</button>
</div>
Expand Down Expand Up @@ -211,7 +211,7 @@ function DogPhoto({ breed }) {
return (
<div>
<img src={data.dog.displayImage} style={{ height: 100, width: 100 }} />
<button onClick={() => refetch({ breed: 'new_dog_breed' })}>
<button onClick={() => refetch()}>
Refetch!
</button>
</div>
Expand Down
19 changes: 15 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"@graphql-typed-document-node/core": "^3.1.1",
"@wry/context": "^0.7.3",
"@wry/equality": "^0.5.6",
"@wry/trie": "^0.4.3",
"@wry/trie": "^0.5.0",
"graphql-tag": "^2.12.6",
"hoist-non-react-statics": "^3.3.2",
"optimism": "^0.17.5",
Expand Down
2 changes: 1 addition & 1 deletion src/react/components/__tests__/client/Query.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ describe("Query component", () => {
return (
<AllPeopleQuery2 query={query} notifyOnNetworkStatusChange={true}>
{(r: any) => {
ProfiledContainer.updateSnapshot(r);
ProfiledContainer.replaceSnapshot(r);
return null;
}}
</AllPeopleQuery2>
Expand Down
2 changes: 1 addition & 1 deletion src/react/hoc/__tests__/queries/lifecycle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe("[queries] lifecycle", () => {
})(
class extends React.Component<ChildProps<Vars, Data, Vars>> {
render() {
ProfiledApp.updateSnapshot(this.props.data!);
ProfiledApp.replaceSnapshot(this.props.data!);
return null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/react/hoc/__tests__/queries/loading.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ describe("[queries] loading", () => {
})(
class extends React.Component<ChildProps<{}, Data>> {
render() {
ProfiledContainer.updateSnapshot(this.props.data!);
ProfiledContainer.replaceSnapshot(this.props.data!);
return null;
}
}
Expand Down
19 changes: 8 additions & 11 deletions src/react/hooks/__tests__/useBackgroundQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ function renderVariablesIntegrationTest({
const ProfiledApp = profile<Renders, ComponentProps<typeof App>>({
Component: App,
snapshotDOM: true,
onRender: ({ updateSnapshot }) => updateSnapshot(cloneDeep(renders)),
onRender: ({ replaceSnapshot }) => replaceSnapshot(cloneDeep(renders)),
});

const { ...rest } = render(
Expand Down Expand Up @@ -434,9 +434,8 @@ function renderPaginatedIntegrationTest({
}

function SuspenseFallback() {
ProfiledApp.updateSnapshot((snapshot) => ({
...snapshot,
suspenseCount: snapshot.suspenseCount + 1,
ProfiledApp.mergeSnapshot(({ suspenseCount }) => ({
suspenseCount: suspenseCount + 1,
}));
return <div>loading</div>;
}
Expand All @@ -450,9 +449,8 @@ function renderPaginatedIntegrationTest({
}) {
const { data, error } = useReadQuery(queryRef);
// count renders in the child component
ProfiledApp.updateSnapshot((snapshot) => ({
...snapshot,
count: snapshot.count + 1,
ProfiledApp.mergeSnapshot(({ count }) => ({
count: count + 1,
}));
return (
<div>
Expand Down Expand Up @@ -504,10 +502,9 @@ function renderPaginatedIntegrationTest({
<ErrorBoundary
fallback={<div>Error</div>}
onError={(error) => {
ProfiledApp.updateSnapshot((snapshot) => ({
...snapshot,
errorCount: snapshot.errorCount + 1,
errors: snapshot.errors.concat(error),
ProfiledApp.mergeSnapshot(({ errorCount, errors }) => ({
errorCount: errorCount + 1,
errors: errors.concat(error),
}));
}}
>
Expand Down
2 changes: 1 addition & 1 deletion src/react/hooks/__tests__/useFragment.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ describe("has the same timing as `useQuery`", () => {
from: initialItem,
});

ProfiledComponent.updateSnapshot({ queryData, fragmentData });
ProfiledComponent.replaceSnapshot({ queryData, fragmentData });

return complete ? JSON.stringify(fragmentData) : "loading";
}
Expand Down
2 changes: 1 addition & 1 deletion src/react/hooks/__tests__/useLazyQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ describe("useLazyQuery Hook", () => {
),
});

const [execute] = ProfiledHook.getCurrentSnapshot();
const [execute] = await ProfiledHook.peekSnapshot();

{
const [, result] = await ProfiledHook.takeSnapshot();
Expand Down
2 changes: 1 addition & 1 deletion src/react/hooks/__tests__/useSuspenseQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ describe("useSuspenseQuery", () => {

const Component = () => {
const result = useSuspenseQuery(query);
ProfiledApp.updateSnapshot(result);
ProfiledApp.replaceSnapshot(result);
return <div>{result.data.greeting}</div>;
};

Expand Down
Loading

0 comments on commit 0b3c308

Please sign in to comment.