-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
121 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@apollo/graphql-testing-library": minor | ||
--- | ||
|
||
Defer support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Canvas, Meta, Source } from '@storybook/blocks'; | ||
import * as ApolloStories from './Apollo.stories.ts'; | ||
|
||
<Meta of={ApolloStories} /> | ||
|
||
# Apollo Demo | ||
|
||
The `Apollo/App` and `Apollo/AppWithDefer` stories provide two examples of a MSW handler generated by this library resolving a request originating from a Relay app. | ||
|
||
## `App` query | ||
In `App`, a single JSON response is generated using the mock resolver found in [`src/__tests__/mocks/handlers.ts`](https://github.com/apollographql/graphql-testing-library/blob/main/src/__tests__/mocks/handlers.ts). | ||
|
||
<Source language="graphql" code={` | ||
query AppQuery { | ||
products { | ||
id | ||
reviews { | ||
id | ||
rating | ||
} | ||
title | ||
mediaUrl | ||
} | ||
} | ||
`} /> | ||
|
||
## `AppWithDefer` query | ||
In `AppWithDefer`, the same mock resolver is used to generate the response, but the presence of `@defer` prompts the generated MSW handler to reply with a multipart response using the proposed [incremental delivery over HTTP](https://github.com/graphql/graphql-over-http/blob/main/rfcs/IncrementalDelivery.md) specification. While the inline fragment is pending, the `Reviews` component displays a `-` in place of the missing data. | ||
|
||
<Source language="graphql" code={` | ||
query AppQueryWithDefer { | ||
products { | ||
id | ||
... @defer { | ||
reviews { | ||
id | ||
rating | ||
} | ||
} | ||
title | ||
mediaUrl | ||
} | ||
} | ||
`} /> | ||
|
||
{/* <Canvas of={ApolloStories.AppWithDefer} /> */} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Canvas, Meta, Source } from '@storybook/blocks'; | ||
import * as RelayStories from './Relay.stories.ts'; | ||
|
||
<Meta of={RelayStories} /> | ||
|
||
# Relay Demo | ||
|
||
The `Relay/App` and `Relay/AppWithDefer` stories provide two examples of a MSW handler generated by this library resolving a request originating from a Relay app. | ||
|
||
## `App` query | ||
In `App`, a single JSON response is generated using the mock resolver found in [`src/__tests__/mocks/handlers.ts`](https://github.com/apollographql/graphql-testing-library/blob/main/src/__tests__/mocks/handlers.ts). | ||
|
||
<Source language="graphql" code={` | ||
query RelayComponentWithDeferAppQuery { | ||
products { | ||
id | ||
...RelayComponentReviewsFragment_product | ||
title | ||
mediaUrl | ||
description | ||
} | ||
} | ||
`} /> | ||
|
||
## `AppWithDefer` query | ||
In `AppWithDefer`, the same mock resolver is used to generate the response, but the presence of `@defer` prompts the generated MSW handler to reply with a multipart response using the proposed [incremental delivery over HTTP](https://github.com/graphql/graphql-over-http/blob/main/rfcs/IncrementalDelivery.md) specification. While the `RelayComponentReviewsFragment_product` fragment is suspending, the `Reviews` component displays a `-` fallback. | ||
|
||
<Source language="graphql" code={` | ||
query RelayComponentWithDeferAppQuery { | ||
products { | ||
id | ||
...RelayComponentReviewsFragment_product @defer | ||
title | ||
mediaUrl | ||
description | ||
} | ||
} | ||
`} /> | ||
|
||
{/* <Canvas of={RelayStories.AppWithDefer} /> */} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 6 additions & 23 deletions
29
.storybook/stories/components/relay/__generated__/RelayComponentAppQuery.graphql.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 2 additions & 10 deletions
12
...k/stories/components/relay/__generated__/RelayComponentReviewsFragment_product.graphql.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.