Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor createHandler to createHandlerFromSchema #83

Merged
merged 22 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strange-socks-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/graphql-testing-library": patch
---

Adds `createHandlerFromSchema`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you've also added a bunch of exports for utilities. Would that be worth calling out here or in a separate changeset?

I've also noticed that createHandlerFromSchema is more-or-less the same as createHandler was before this since the old createHandler took a schema as an argument. Would it be worth calling out that breaking change to specify that createHandler now accepts type defs and provides a bunch of the default resolvers for you?

1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
sourceType: "module",
},
plugins: ["@typescript-eslint"],
ignorePatterns: ["**/__generated__/*.ts"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ jobs:
run: pnpm install

- name: Lint
run: pnpm run lint
run: pnpm run prettier

type-check:
name: Check types
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pnpm-lock.yaml
.storybook/public/mockServiceWorker.js
.storybook/public/mockServiceWorker.js
__generated__
2 changes: 1 addition & 1 deletion .storybook/public/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* - Please do NOT serve this file on production.
*/

const PACKAGE_VERSION = '2.3.4'
const PACKAGE_VERSION = '2.3.5'
const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
const activeClientIds = new Set()
Expand Down
15 changes: 4 additions & 11 deletions .storybook/stories/ApolloClient.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,24 @@ import {
ApolloApp,
ApolloAppWithDefer as AppWithDefer,
} from "./components/apollo-client/ApolloComponent.js";
import { createHandler } from "../../src/handlers.js";
import { schemaWithMocks } from "../../src/__tests__/mocks/handlers.js";
import { graphQLHandler } from "../../src/__tests__/mocks/handlers.js";

const { handler } = createHandler(schemaWithMocks);

const meta = {
export default {
title: "Example/Apollo Client",
component: ApolloApp,
parameters: {
layout: "centered",
msw: {
handlers: {
graphql: handler,
graphql: graphQLHandler,
},
},
},
} satisfies Meta<typeof ApolloApp>;

export default meta;

export { AppWithDefer };

type Story = StoryObj<typeof meta>;

export const App: Story = {
export const App: StoryObj<typeof ApolloApp> = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await expect(
Expand Down
15 changes: 4 additions & 11 deletions .storybook/stories/Relay.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,24 @@ import {
RelayApp,
RelayAppWithDefer as AppWithDefer,
} from "./components/relay/RelayComponent.js";
import { createHandler } from "../../src/handlers.js";
import { schemaWithMocks } from "../../src/__tests__/mocks/handlers.js";
import { graphQLHandler } from "../../src/__tests__/mocks/handlers.js";

const { handler } = createHandler(schemaWithMocks);

const meta = {
export default {
title: "Example/Relay",
component: RelayApp,
parameters: {
layout: "centered",
msw: {
handlers: {
graphql: handler,
graphql: graphQLHandler,
},
},
},
} satisfies Meta<typeof RelayApp>;

export default meta;

export { AppWithDefer };

type Story = StoryObj<typeof meta>;

export const App: Story = {
export const App: StoryObj<typeof RelayApp> = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await expect(
Expand Down

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

Loading