Skip to content

Commit

Permalink
useSuspenseQuery (#10323)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Dec 9, 2022
1 parent 7755708 commit 64cb88a
Show file tree
Hide file tree
Showing 26 changed files with 4,770 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/small-timers-shake.md
@@ -0,0 +1,5 @@
---
'@apollo/client': minor
---

Add support for React suspense with a new `useSuspenseQuery` hook.
35 changes: 35 additions & 0 deletions .prettierignore
@@ -1,6 +1,41 @@
##### DISCLAIMER ######
# We have disabled the use of prettier in this project for a variety of reasons.
# Because much of this project has not been formatted, we don't want to want to
# apply formatting to everything and skew `git blame` stats. Instead, we should
# only format newly created files that we can guarantee have no existing git
# history. For this reason, we have disabled prettier project-wide except for
# a handful of files.
#
# ONLY ADD NEWLY CREATED FILES/PATHS TO THE LIST BELOW. DO NOT ADD EXISTING
# PROJECT FILES.

# ignores all files in /docs directory
/docs/**

# Ignore all mdx & md files:
*.mdx
*.md

# Do not format anything automatically except files listed below
/*

##### PATHS TO BE FORMATTED #####
!src/
src/*
!src/react/
src/react/*

# Allow src/react/cache
!src/react/cache/

## Allowed React Hooks
!src/react/hooks/
src/react/hooks/*
!src/react/hooks/internal
!src/react/hooks/useSuspenseCache.ts
!src/react/hooks/useSuspenseQuery.ts

## Allowed React hook tests
!src/react/hooks/__tests__/
src/react/hooks/__tests__/*
!src/react/hooks/__tests__/useSuspenseQuery.test.tsx
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,10 @@
## Apollo Client 3.8.0

### Bug fixes

- Avoid calling `useQuery` `onCompleted` callback after cache writes, only after the originating query's network request(s) complete. <br/>
[@alessbell](https://github.com/alessbell) in [#10229](https://github.com/apollographql/apollo-client/pull/10229)

## Apollo Client 3.7.2 (2022-12-06)

### Improvements
Expand Down
2 changes: 1 addition & 1 deletion config/bundlesize.ts
Expand Up @@ -3,7 +3,7 @@ import { join } from "path";
import { gzipSync } from "zlib";
import bytes from "bytes";

const gzipBundleByteLengthLimit = bytes("31.87KB");
const gzipBundleByteLengthLimit = bytes("32.79KB");
const minFile = join("dist", "apollo-client.min.cjs");
const minPath = join(__dirname, "..", minFile);
const gzipByteLen = gzipSync(readFileSync(minPath)).byteLength;
Expand Down
11 changes: 9 additions & 2 deletions config/jest.config.js
Expand Up @@ -2,7 +2,7 @@ const defaults = {
rootDir: "src",
preset: "ts-jest",
testEnvironment: "jsdom",
setupFiles: ["<rootDir>/config/jest/setup.ts"],
setupFilesAfterEnv: ["<rootDir>/config/jest/setup.ts"],
testEnvironmentOptions: {
url: "http://localhost",
},
Expand All @@ -25,6 +25,13 @@ const defaults = {
const ignoreTSFiles = '.ts$';
const ignoreTSXFiles = '.tsx$';

const react17TestFileIgnoreList = [
ignoreTSFiles,
// For now, we only support useSuspenseQuery with React 18, so no need to test
// it with React 17
'src/react/hooks/__tests__/useSuspenseQuery.test.tsx'
]

const react18TestFileIgnoreList = [
// ignore core tests (.ts files) as they are run separately
// to avoid running them twice with both react versions
Expand Down Expand Up @@ -68,7 +75,7 @@ const standardReact18Config = {
const standardReact17Config = {
...defaults,
displayName: "ReactDOM 17",
testPathIgnorePatterns: [ignoreTSFiles],
testPathIgnorePatterns: react17TestFileIgnoreList,
moduleNameMapper: {
"^react$": "react-17",
"^react-dom$": "react-dom-17",
Expand Down

0 comments on commit 64cb88a

Please sign in to comment.