Skip to content

Commit 570f021

Browse files
committed
Add @defer support (#17)
1 parent a5d79be commit 570f021

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+18055
-1
lines changed

.changeset/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{ "repo": "apollographql/graphql-testing-library" }
6+
],
7+
"commit": false,
8+
"fixed": [],
9+
"linked": [],
10+
"access": "public",
11+
"baseBranch": "main",
12+
"updateInternalDependencies": "patch",
13+
"ignore": []
14+
}

.changeset/strong-llamas-wash.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@apollo/graphql-testing-library": minor
3+
---
4+
5+
Defer support

.eslintrc.cjs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/** @type {import("@types/eslint").Linter.Config} */
2+
// eslint-disable-next-line no-undef
3+
module.exports = {
4+
env: {
5+
browser: true,
6+
node: true,
7+
es2021: true,
8+
},
9+
extends: [
10+
"eslint:recommended",
11+
"plugin:@typescript-eslint/recommended",
12+
"plugin:storybook/recommended",
13+
],
14+
overrides: [],
15+
parser: "@typescript-eslint/parser",
16+
parserOptions: {
17+
ecmaVersion: "latest",
18+
sourceType: "module",
19+
},
20+
plugins: ["@typescript-eslint"],
21+
rules: {
22+
"@typescript-eslint/no-explicit-any": "off",
23+
"@typescript-eslint/no-unused-vars": [
24+
"warn",
25+
{
26+
args: "all",
27+
argsIgnorePattern: "^_",
28+
caughtErrors: "all",
29+
caughtErrorsIgnorePattern: "^_",
30+
destructuredArrayIgnorePattern: "^_",
31+
varsIgnorePattern: "^_",
32+
ignoreRestSiblings: true,
33+
},
34+
],
35+
"@typescript-eslint/consistent-type-imports": [
36+
"error",
37+
{
38+
prefer: "type-imports",
39+
disallowTypeAnnotations: false,
40+
fixStyle: "separate-type-imports",
41+
},
42+
],
43+
},
44+
};
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Deploy Storybook
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
jobs:
14+
deploy:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- uses: pnpm/action-setup@v4
21+
name: Install pnpm
22+
with:
23+
version: 9
24+
run_install: false
25+
26+
- name: Install Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 20
30+
cache: 'pnpm'
31+
32+
- name: Install dependencies
33+
run: pnpm install
34+
35+
- name: Build and publish
36+
id: build-publish
37+
uses: bitovi/[email protected]
38+
with:
39+
path: storybook-static
40+
build_command: pnpm run build-storybook
41+
install_command: pnpm i
42+
checkout: false

.github/workflows/release.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
release:
12+
name: Changesets Release
13+
# Prevents action from creating a PR on forks
14+
if: github.repository == 'apollographql/graphql-testing-library'
15+
runs-on: ubuntu-latest
16+
# Permissions necessary for Changesets to push a new branch and open PRs
17+
# (for automated Version Packages PRs), and request the JWT for provenance.
18+
# More info: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings
19+
permissions:
20+
contents: write
21+
pull-requests: write
22+
id-token: write
23+
steps:
24+
- name: Checkout repo
25+
uses: actions/checkout@v4
26+
with:
27+
# Fetch entire git history so Changesets can generate changelogs
28+
# with the correct commits
29+
fetch-depth: 0
30+
31+
- name: Check for pre.json file existence
32+
id: check_files
33+
uses: andstor/[email protected]
34+
with:
35+
files: ".changeset/pre.json"
36+
37+
- name: Append NPM token to .npmrc
38+
run: |
39+
cat << EOF > "$HOME/.npmrc"
40+
provenance=true
41+
//registry.npmjs.org/:_authToken=$NPM_TOKEN
42+
EOF
43+
env:
44+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
46+
- name: Setup Node.js 20.x
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: 20.x
50+
51+
- name: Install pnpm and dependencies
52+
uses: pnpm/action-setup@v4
53+
with:
54+
version: 9
55+
run_install: true
56+
57+
- name: Create release PR or publish to npm + GitHub
58+
id: changesets
59+
if: steps.check_files.outputs.files_exists == 'false'
60+
uses: changesets/action@v1
61+
with:
62+
version: pnpm run changeset-version
63+
publish: pnpm run changeset-publish
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: Run
2+
3+
on: [push]
4+
5+
concurrency: ${{ github.workflow }}-${{ github.ref }}
6+
7+
jobs:
8+
install-and-cache:
9+
name: Install and cache
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- uses: pnpm/action-setup@v4
17+
name: Install pnpm
18+
with:
19+
version: 9
20+
run_install: false
21+
22+
- name: Install Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 20
26+
cache: 'pnpm'
27+
28+
- name: Get pnpm store directory
29+
shell: bash
30+
run: |
31+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
32+
33+
- uses: actions/cache@v4
34+
name: Setup pnpm cache
35+
with:
36+
path: ${{ env.STORE_PATH }}
37+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
38+
restore-keys: |
39+
${{ runner.os }}-pnpm-store-
40+
41+
- name: Install dependencies
42+
run: pnpm install
43+
44+
test-jest:
45+
name: Jest tests
46+
if: github.repository == 'apollographql/graphql-testing-library'
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout repo
50+
uses: actions/checkout@v4
51+
52+
- name: Install pnpm
53+
uses: pnpm/action-setup@v4
54+
with:
55+
version: 9
56+
run_install: false
57+
58+
- name: Install Node.js
59+
uses: actions/setup-node@v4
60+
with:
61+
node-version: 20
62+
cache: 'pnpm'
63+
64+
- name: Install dependencies
65+
run: pnpm install
66+
67+
- name: Run Jest tests
68+
run: pnpm run test
69+
70+
test-playwright:
71+
name: Playwright tests
72+
if: github.repository == 'apollographql/graphql-testing-library'
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout repo
76+
uses: actions/checkout@v4
77+
78+
- name: Install pnpm
79+
uses: pnpm/action-setup@v4
80+
with:
81+
version: 9
82+
run_install: false
83+
84+
- name: Install Node.js
85+
uses: actions/setup-node@v4
86+
with:
87+
node-version: 20
88+
cache: 'pnpm'
89+
90+
- name: Install dependencies
91+
run: pnpm install
92+
93+
- name: Get installed Playwright version
94+
id: playwright-version
95+
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package.json').devDependencies['@playwright/test'])")" >> $GITHUB_ENV
96+
97+
- name: Cache Playwright binaries
98+
uses: actions/cache@v3
99+
id: playwright-cache
100+
with:
101+
path: |
102+
~/.cache/ms-playwright
103+
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
104+
105+
- run: npx playwright install --with-deps
106+
if: steps.playwright-cache.outputs.cache-hit != 'true'
107+
108+
- name: Serve Storybook and run tests
109+
run: pnpm run build-and-test-storybook
110+
111+
lint:
112+
name: Lint
113+
if: github.repository == 'apollographql/graphql-testing-library'
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: Checkout repo
117+
uses: actions/checkout@v4
118+
119+
- name: Install pnpm
120+
uses: pnpm/action-setup@v4
121+
with:
122+
version: 9
123+
run_install: false
124+
125+
- name: Install Node.js
126+
uses: actions/setup-node@v4
127+
with:
128+
node-version: 20
129+
cache: 'pnpm'
130+
131+
- name: Install dependencies
132+
run: pnpm install
133+
134+
- name: Lint
135+
run: pnpm run lint
136+
137+
type-check:
138+
name: Check types
139+
if: github.repository == 'apollographql/graphql-testing-library'
140+
runs-on: ubuntu-latest
141+
steps:
142+
- name: Checkout repo
143+
uses: actions/checkout@v4
144+
145+
- name: Install pnpm
146+
uses: pnpm/action-setup@v4
147+
with:
148+
version: 9
149+
run_install: false
150+
151+
- name: Install Node.js
152+
uses: actions/setup-node@v4
153+
with:
154+
node-version: 20
155+
cache: 'pnpm'
156+
157+
- name: Install dependencies
158+
run: pnpm install
159+
160+
- name: Check types
161+
run: pnpm run type-check

.gitignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.yarn/*
2+
!.yarn/patches
3+
!.yarn/plugins
4+
!.yarn/releases
5+
!.yarn/sdks
6+
!.yarn/versions
7+
node_modules/
8+
tsconfig.tsbuildinfo
9+
dist/
10+
.yalc
11+
yalc.lock
12+
*.tgz
13+
.DS_Store
14+
.vscode/
15+
.vercel
16+
.next/
17+
test-results/
18+
temp/
19+
*storybook.log
20+
21+
# output of storybook-build
22+
storybook-static

.storybook/main.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { StorybookConfig } from "@storybook/react-vite";
2+
import relay from "vite-plugin-relay";
3+
import graphqlLoader from "vite-plugin-graphql-loader";
4+
5+
const config: StorybookConfig = {
6+
stories: ["./**/*.mdx", "./**/*.stories.@(js|jsx|mjs|ts|tsx)"],
7+
addons: [
8+
"@storybook/addon-links",
9+
"@storybook/addon-essentials",
10+
"@storybook/addon-interactions",
11+
"@storybook/addon-styling-webpack",
12+
"@storybook/addon-docs",
13+
],
14+
framework: {
15+
name: "@storybook/react-vite",
16+
options: {},
17+
},
18+
async viteFinal(config, options) {
19+
// Add your configuration here
20+
config.plugins?.push(relay, graphqlLoader());
21+
return config;
22+
},
23+
};
24+
25+
export default config;

0 commit comments

Comments
 (0)