Skip to content

Commit 64cb88a

Browse files
authored
useSuspenseQuery (#10323)
1 parent 7755708 commit 64cb88a

26 files changed

Lines changed: 4770 additions & 19 deletions

.changeset/small-timers-shake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@apollo/client': minor
3+
---
4+
5+
Add support for React suspense with a new `useSuspenseQuery` hook.

.prettierignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
1+
##### DISCLAIMER ######
2+
# We have disabled the use of prettier in this project for a variety of reasons.
3+
# Because much of this project has not been formatted, we don't want to want to
4+
# apply formatting to everything and skew `git blame` stats. Instead, we should
5+
# only format newly created files that we can guarantee have no existing git
6+
# history. For this reason, we have disabled prettier project-wide except for
7+
# a handful of files.
8+
#
9+
# ONLY ADD NEWLY CREATED FILES/PATHS TO THE LIST BELOW. DO NOT ADD EXISTING
10+
# PROJECT FILES.
11+
112
# ignores all files in /docs directory
213
/docs/**
314

415
# Ignore all mdx & md files:
516
*.mdx
617
*.md
18+
19+
# Do not format anything automatically except files listed below
20+
/*
21+
22+
##### PATHS TO BE FORMATTED #####
23+
!src/
24+
src/*
25+
!src/react/
26+
src/react/*
27+
28+
# Allow src/react/cache
29+
!src/react/cache/
30+
31+
## Allowed React Hooks
32+
!src/react/hooks/
33+
src/react/hooks/*
34+
!src/react/hooks/internal
35+
!src/react/hooks/useSuspenseCache.ts
36+
!src/react/hooks/useSuspenseQuery.ts
37+
38+
## Allowed React hook tests
39+
!src/react/hooks/__tests__/
40+
src/react/hooks/__tests__/*
41+
!src/react/hooks/__tests__/useSuspenseQuery.test.tsx

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## Apollo Client 3.8.0
2+
3+
### Bug fixes
4+
5+
- Avoid calling `useQuery` `onCompleted` callback after cache writes, only after the originating query's network request(s) complete. <br/>
6+
[@alessbell](https://github.com/alessbell) in [#10229](https://github.com/apollographql/apollo-client/pull/10229)
7+
18
## Apollo Client 3.7.2 (2022-12-06)
29

310
### Improvements

config/bundlesize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { join } from "path";
33
import { gzipSync } from "zlib";
44
import bytes from "bytes";
55

6-
const gzipBundleByteLengthLimit = bytes("31.87KB");
6+
const gzipBundleByteLengthLimit = bytes("32.79KB");
77
const minFile = join("dist", "apollo-client.min.cjs");
88
const minPath = join(__dirname, "..", minFile);
99
const gzipByteLen = gzipSync(readFileSync(minPath)).byteLength;

config/jest.config.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const defaults = {
22
rootDir: "src",
33
preset: "ts-jest",
44
testEnvironment: "jsdom",
5-
setupFiles: ["<rootDir>/config/jest/setup.ts"],
5+
setupFilesAfterEnv: ["<rootDir>/config/jest/setup.ts"],
66
testEnvironmentOptions: {
77
url: "http://localhost",
88
},
@@ -25,6 +25,13 @@ const defaults = {
2525
const ignoreTSFiles = '.ts$';
2626
const ignoreTSXFiles = '.tsx$';
2727

28+
const react17TestFileIgnoreList = [
29+
ignoreTSFiles,
30+
// For now, we only support useSuspenseQuery with React 18, so no need to test
31+
// it with React 17
32+
'src/react/hooks/__tests__/useSuspenseQuery.test.tsx'
33+
]
34+
2835
const react18TestFileIgnoreList = [
2936
// ignore core tests (.ts files) as they are run separately
3037
// to avoid running them twice with both react versions
@@ -68,7 +75,7 @@ const standardReact18Config = {
6875
const standardReact17Config = {
6976
...defaults,
7077
displayName: "ReactDOM 17",
71-
testPathIgnorePatterns: [ignoreTSFiles],
78+
testPathIgnorePatterns: react17TestFileIgnoreList,
7279
moduleNameMapper: {
7380
"^react$": "react-17",
7481
"^react-dom$": "react-dom-17",

0 commit comments

Comments
 (0)