Skip to content

Commit 958c625

Browse files
committed
wip
1 parent b4f85b9 commit 958c625

File tree

11 files changed

+2311
-89
lines changed

11 files changed

+2311
-89
lines changed

.storybook/stories/ApolloClient.stories.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ import {
44
ApolloApp,
55
ApolloAppWithDefer as AppWithDefer,
66
} from "./components/apollo-client/ApolloComponent.js";
7-
import { createHandler } from "../../src/handlers.js";
8-
import { schemaWithMocks } from "../../src/__tests__/mocks/handlers.js";
7+
import { handler } from "../../src/__tests__/mocks/handlers.js";
98

10-
const { handler } = createHandler(schemaWithMocks);
11-
12-
const meta = {
9+
export default {
1310
title: "Example/Apollo Client",
1411
component: ApolloApp,
1512
parameters: {
@@ -22,13 +19,9 @@ const meta = {
2219
},
2320
} satisfies Meta<typeof ApolloApp>;
2421

25-
export default meta;
26-
2722
export { AppWithDefer };
2823

29-
type Story = StoryObj<typeof meta>;
30-
31-
export const App: Story = {
24+
export const App: StoryObj<typeof ApolloApp> = {
3225
play: async ({ canvasElement }) => {
3326
const canvas = within(canvasElement);
3427
await expect(

.storybook/stories/Relay.stories.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ import {
44
RelayApp,
55
RelayAppWithDefer as AppWithDefer,
66
} from "./components/relay/RelayComponent.js";
7-
import { createHandler } from "../../src/handlers.js";
8-
import { schemaWithMocks } from "../../src/__tests__/mocks/handlers.js";
7+
import { handler } from "../../src/__tests__/mocks/handlers.js";
98

10-
const { handler } = createHandler(schemaWithMocks);
11-
12-
const meta = {
9+
export default {
1310
title: "Example/Relay",
1411
component: RelayApp,
1512
parameters: {
@@ -22,13 +19,9 @@ const meta = {
2219
},
2320
} satisfies Meta<typeof RelayApp>;
2421

25-
export default meta;
26-
2722
export { AppWithDefer };
2823

29-
type Story = StoryObj<typeof meta>;
30-
31-
export const App: Story = {
24+
export const App: StoryObj<typeof RelayApp> = {
3225
play: async ({ canvasElement }) => {
3326
const canvas = within(canvasElement);
3427
await expect(

codegen.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { CodegenConfig } from "@graphql-codegen/cli";
2+
3+
const config: CodegenConfig = {
4+
hooks: {
5+
afterAllFileWrite: ["prettier --write"],
6+
},
7+
schema: "./.storybook/stories/components/relay/schema.graphql",
8+
generates: {
9+
"./src/__generated__/resolvers-types.ts": {
10+
plugins: ["typescript", "typescript-resolvers"],
11+
},
12+
},
13+
};
14+
15+
export default config;

jest.polyfills.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,24 @@
1111

1212
const { TextDecoder, TextEncoder } = require("node:util");
1313
const { ReadableStream } = require("node:stream/web");
14-
const { clearImmediate } = require("node:timers");
15-
const { performance } = require("node:perf_hooks");
1614

1715
Object.defineProperties(globalThis, {
18-
TextDecoder: { value: TextDecoder }, // jest
19-
TextEncoder: { value: TextEncoder }, // jest
20-
ReadableStream: { value: ReadableStream }, // jest
21-
performance: { value: performance },
22-
clearImmediate: { value: clearImmediate },
16+
TextDecoder: { value: TextDecoder },
17+
TextEncoder: { value: TextEncoder },
18+
ReadableStream: { value: ReadableStream },
2319
});
2420

2521
const { Blob, File } = require("node:buffer");
2622
const { fetch, Headers, FormData, Request, Response } = require("undici");
2723

2824
Object.defineProperties(globalThis, {
29-
fetch: { value: fetch, writable: true }, // jest
25+
fetch: { value: fetch, writable: true },
3026
Blob: { value: Blob },
3127
File: { value: File },
3228
Headers: { value: Headers },
3329
FormData: { value: FormData },
3430
Request: { value: Request },
35-
Response: { value: Response }, // jest
31+
Response: { value: Response },
3632
});
3733

3834
// Symbol.dispose is not defined

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"changeset-publish": "pnpm run clean && pnpm run build && pnpm run prepdist:changesets && cd dist && changeset publish",
3737
"changeset-version": "changeset version && pnpm i",
3838
"changeset-check": "changeset status --verbose --since=origin/main",
39+
"generate-types": "graphql-codegen --config codegen.ts",
3940
"test:jest": "jest",
4041
"test:vitest": "vitest run",
4142
"test:storybook": "test-storybook",
@@ -53,10 +54,11 @@
5354
"@apollo/client": "3.11.0",
5455
"@changesets/changelog-github": "0.5.0",
5556
"@changesets/cli": "2.27.6",
57+
"@graphql-codegen/cli": "5.0.2",
58+
"@graphql-codegen/typescript": "4.0.9",
59+
"@graphql-codegen/typescript-resolvers": "4.2.1",
5660
"@graphql-tools/jest-transform": "2.0.0",
5761
"@graphql-tools/merge": "9.0.4",
58-
"@graphql-tools/mock": "9.0.3",
59-
"@graphql-tools/schema": "10.0.4",
6062
"@playwright/test": "1.45.0",
6163
"@storybook/addon-docs": "8.2.2",
6264
"@storybook/addon-essentials": "8.2.2",
@@ -116,6 +118,8 @@
116118
},
117119
"dependencies": {
118120
"@graphql-tools/executor": "^1.2.7",
121+
"@graphql-tools/mock": "^9.0.4",
122+
"@graphql-tools/schema": "^10.0.4",
119123
"graphql-tag": "^2.12.6",
120124
"is-node-process": "^1.2.0"
121125
},

0 commit comments

Comments
 (0)