@khanacademy/wonder-blocks-data 10.1.0 → 10.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/dist/components/data.d.ts +52 -0
- package/dist/components/data.js.flow +63 -0
- package/dist/components/gql-router.d.ts +24 -0
- package/dist/components/gql-router.js.flow +33 -0
- package/dist/components/intercept-context.d.ts +10 -0
- package/dist/components/intercept-context.js.flow +19 -0
- package/dist/components/intercept-requests.d.ts +42 -0
- package/dist/components/intercept-requests.js.flow +51 -0
- package/dist/components/track-data.d.ts +11 -0
- package/dist/components/track-data.js.flow +18 -0
- package/dist/es/index.js +184 -212
- package/dist/hooks/use-cached-effect.d.ts +70 -0
- package/dist/hooks/use-cached-effect.js.flow +85 -0
- package/dist/hooks/use-gql-router-context.d.ts +5 -0
- package/dist/hooks/use-gql-router-context.js.flow +15 -0
- package/dist/hooks/use-gql.d.ts +12 -0
- package/dist/hooks/use-gql.js.flow +29 -0
- package/dist/hooks/use-hydratable-effect.d.ts +102 -0
- package/dist/hooks/use-hydratable-effect.js.flow +125 -0
- package/dist/hooks/use-request-interception.d.ts +14 -0
- package/dist/hooks/use-request-interception.js.flow +25 -0
- package/dist/hooks/use-server-effect.d.ts +39 -0
- package/dist/hooks/use-server-effect.js.flow +51 -0
- package/dist/hooks/use-shared-cache.d.ts +32 -0
- package/dist/hooks/use-shared-cache.js.flow +43 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +186 -217
- package/dist/index.js.flow +48 -2
- package/dist/util/data-error.d.ts +45 -0
- package/dist/util/data-error.js.flow +64 -0
- package/dist/util/get-gql-data-from-response.d.ts +4 -0
- package/dist/util/get-gql-data-from-response.js.flow +13 -0
- package/dist/util/get-gql-request-id.d.ts +5 -0
- package/dist/util/get-gql-request-id.js.flow +20 -0
- package/dist/util/gql-error.d.ts +28 -0
- package/dist/util/gql-error.js.flow +43 -0
- package/dist/util/gql-router-context.d.ts +3 -0
- package/dist/util/gql-router-context.js.flow +10 -0
- package/dist/util/gql-types.d.ts +34 -0
- package/dist/util/gql-types.js.flow +53 -0
- package/dist/util/graphql-document-node-parser.d.ts +18 -0
- package/dist/util/graphql-document-node-parser.js.flow +31 -0
- package/dist/util/graphql-types.d.ts +19 -0
- package/dist/util/graphql-types.js.flow +30 -0
- package/dist/util/hydration-cache-api.d.ts +17 -0
- package/dist/util/hydration-cache-api.js.flow +30 -0
- package/dist/util/merge-gql-context.d.ts +8 -0
- package/dist/util/merge-gql-context.js.flow +19 -0
- package/dist/util/purge-caches.d.ts +8 -0
- package/dist/util/purge-caches.js.flow +15 -0
- package/dist/util/request-api.d.ts +28 -0
- package/dist/util/request-api.js.flow +34 -0
- package/dist/util/request-fulfillment.d.ts +37 -0
- package/dist/util/request-fulfillment.js.flow +50 -0
- package/dist/util/request-tracking.d.ts +62 -0
- package/dist/util/request-tracking.js.flow +81 -0
- package/dist/util/result-from-cache-response.d.ts +5 -0
- package/dist/util/result-from-cache-response.js.flow +15 -0
- package/dist/util/scoped-in-memory-cache.d.ts +38 -0
- package/dist/util/scoped-in-memory-cache.js.flow +57 -0
- package/dist/util/serializable-in-memory-cache.d.ts +16 -0
- package/dist/util/serializable-in-memory-cache.js.flow +26 -0
- package/dist/util/ssr-cache.d.ts +51 -0
- package/dist/util/ssr-cache.js.flow +87 -0
- package/dist/util/status.d.ts +10 -0
- package/dist/util/status.js.flow +19 -0
- package/dist/util/to-gql-operation.d.ts +32 -0
- package/dist/util/to-gql-operation.js.flow +45 -0
- package/dist/util/types.d.ts +111 -0
- package/dist/util/types.js.flow +151 -0
- package/package.json +5 -6
- package/src/components/__tests__/{data.test.js → data.test.tsx} +42 -2
- package/src/components/__tests__/{gql-router.test.js → gql-router.test.tsx} +4 -5
- package/src/components/__tests__/{intercept-requests.test.js → intercept-requests.test.tsx} +2 -3
- package/src/components/__tests__/{track-data.test.js → track-data.test.tsx} +2 -3
- package/src/components/{data.js → data.ts} +11 -15
- package/src/components/{gql-router.js → gql-router.tsx} +12 -14
- package/src/components/{intercept-context.js → intercept-context.ts} +4 -3
- package/src/components/{intercept-requests.js → intercept-requests.tsx} +7 -8
- package/src/components/{track-data.js → track-data.tsx} +4 -5
- package/src/hooks/__tests__/{use-cached-effect.test.js → use-cached-effect.test.tsx} +55 -50
- package/src/hooks/__tests__/{use-gql-router-context.test.js → use-gql-router-context.test.tsx} +7 -7
- package/src/hooks/__tests__/{use-gql.test.js → use-gql.test.tsx} +20 -21
- package/src/hooks/__tests__/{use-hydratable-effect.test.js → use-hydratable-effect.test.ts} +42 -37
- package/src/hooks/__tests__/{use-request-interception.test.js → use-request-interception.test.tsx} +5 -3
- package/src/hooks/__tests__/{use-server-effect.test.js → use-server-effect.test.ts} +8 -2
- package/src/hooks/__tests__/{use-shared-cache.test.js → use-shared-cache.test.ts} +12 -12
- package/src/hooks/{use-cached-effect.js → use-cached-effect.ts} +27 -20
- package/src/hooks/{use-gql-router-context.js → use-gql-router-context.ts} +2 -3
- package/src/hooks/{use-gql.js → use-gql.ts} +5 -5
- package/src/hooks/{use-hydratable-effect.js → use-hydratable-effect.ts} +53 -58
- package/src/hooks/{use-request-interception.js → use-request-interception.ts} +4 -4
- package/src/hooks/{use-server-effect.js → use-server-effect.ts} +7 -9
- package/src/hooks/{use-shared-cache.js → use-shared-cache.ts} +13 -8
- package/src/{index.js → index.ts} +0 -1
- package/src/util/__tests__/{get-gql-data-from-response.test.js → get-gql-data-from-response.test.ts} +0 -1
- package/src/util/__tests__/{get-gql-request-id.test.js → get-gql-request-id.test.ts} +9 -11
- package/src/util/__tests__/{graphql-document-node-parser.test.js → graphql-document-node-parser.test.ts} +11 -12
- package/src/util/__tests__/{hydration-cache-api.test.js → hydration-cache-api.test.ts} +1 -2
- package/src/util/__tests__/{merge-gql-context.test.js → merge-gql-context.test.ts} +4 -5
- package/src/util/__tests__/{purge-caches.test.js → purge-caches.test.ts} +0 -1
- package/src/util/__tests__/{request-api.test.js → request-api.test.ts} +2 -2
- package/src/util/__tests__/{request-fulfillment.test.js → request-fulfillment.test.ts} +0 -1
- package/src/util/__tests__/{request-tracking.test.js → request-tracking.test.tsx} +13 -6
- package/src/util/__tests__/{result-from-cache-response.test.js → result-from-cache-response.test.ts} +2 -4
- package/src/util/__tests__/{scoped-in-memory-cache.test.js → scoped-in-memory-cache.test.ts} +4 -5
- package/src/util/__tests__/{serializable-in-memory-cache.test.js → serializable-in-memory-cache.test.ts} +7 -7
- package/src/util/__tests__/{ssr-cache.test.js → ssr-cache.test.ts} +3 -2
- package/src/util/__tests__/{to-gql-operation.test.js → to-gql-operation.test.ts} +2 -1
- package/src/util/{data-error.js → data-error.ts} +2 -3
- package/src/util/{get-gql-data-from-response.js → get-gql-data-from-response.ts} +1 -6
- package/src/util/{get-gql-request-id.js → get-gql-request-id.ts} +12 -16
- package/src/util/{gql-error.js → gql-error.ts} +2 -3
- package/src/util/gql-router-context.ts +6 -0
- package/src/util/{gql-types.js → gql-types.ts} +27 -23
- package/src/util/{graphql-document-node-parser.js → graphql-document-node-parser.ts} +6 -7
- package/src/util/graphql-types.ts +27 -0
- package/src/util/{hydration-cache-api.js → hydration-cache-api.ts} +4 -2
- package/src/util/{merge-gql-context.js → merge-gql-context.ts} +2 -2
- package/src/util/{purge-caches.js → purge-caches.ts} +0 -1
- package/src/util/{request-api.js → request-api.ts} +0 -1
- package/src/util/{request-fulfillment.js → request-fulfillment.ts} +13 -12
- package/src/util/{request-tracking.js → request-tracking.ts} +12 -13
- package/src/util/{result-from-cache-response.js → result-from-cache-response.ts} +3 -4
- package/src/util/{scoped-in-memory-cache.js → scoped-in-memory-cache.ts} +1 -2
- package/src/util/{serializable-in-memory-cache.js → serializable-in-memory-cache.ts} +2 -3
- package/src/util/{ssr-cache.js → ssr-cache.ts} +19 -18
- package/src/util/{status.js → status.ts} +4 -5
- package/src/util/{to-gql-operation.js → to-gql-operation.ts} +1 -2
- package/src/util/{types.js → types.ts} +39 -48
- package/tsconfig.json +11 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/src/__docs__/_overview_.stories.mdx +0 -18
- package/src/__docs__/_overview_graphql.stories.mdx +0 -35
- package/src/__docs__/_overview_ssr_.stories.mdx +0 -185
- package/src/__docs__/_overview_testing_.stories.mdx +0 -123
- package/src/__docs__/exports.abort-inflight-requests.stories.mdx +0 -20
- package/src/__docs__/exports.data-error.stories.mdx +0 -23
- package/src/__docs__/exports.data-errors.stories.mdx +0 -23
- package/src/__docs__/exports.data.stories.mdx +0 -146
- package/src/__docs__/exports.fetch-tracked-requests.stories.mdx +0 -24
- package/src/__docs__/exports.get-gql-request-id.stories.mdx +0 -24
- package/src/__docs__/exports.gql-error.stories.mdx +0 -23
- package/src/__docs__/exports.gql-errors.stories.mdx +0 -20
- package/src/__docs__/exports.gql-router.stories.mdx +0 -29
- package/src/__docs__/exports.has-tracked-requests-to-be-fetched.stories.mdx +0 -20
- package/src/__docs__/exports.intercept-requests.stories.mdx +0 -69
- package/src/__docs__/exports.intialize-hydration-cache.stories.mdx +0 -29
- package/src/__docs__/exports.purge-caches.stories.mdx +0 -23
- package/src/__docs__/exports.purge-hydration-cache.stories.mdx +0 -24
- package/src/__docs__/exports.scoped-in-memory-cache.stories.mdx +0 -92
- package/src/__docs__/exports.serializable-in-memory-cache.stories.mdx +0 -112
- package/src/__docs__/exports.shared-cache.stories.mdx +0 -16
- package/src/__docs__/exports.status.stories.mdx +0 -31
- package/src/__docs__/exports.track-data.stories.mdx +0 -209
- package/src/__docs__/exports.use-cached-effect.stories.mdx +0 -44
- package/src/__docs__/exports.use-gql.stories.mdx +0 -41
- package/src/__docs__/exports.use-hydratable-effect.stories.mdx +0 -43
- package/src/__docs__/exports.use-server-effect.stories.mdx +0 -50
- package/src/__docs__/exports.use-shared-cache.stories.mdx +0 -30
- package/src/__docs__/exports.when-client-side.stories.mdx +0 -33
- package/src/__docs__/types.cached-response.stories.mdx +0 -29
- package/src/__docs__/types.error-options.stories.mdx +0 -21
- package/src/__docs__/types.fetch-policy.stories.mdx +0 -44
- package/src/__docs__/types.gql-context.stories.mdx +0 -20
- package/src/__docs__/types.gql-fetch-fn.stories.mdx +0 -24
- package/src/__docs__/types.gql-fetch-options.stories.mdx +0 -24
- package/src/__docs__/types.gql-operation-type.stories.mdx +0 -24
- package/src/__docs__/types.gql-operation.stories.mdx +0 -67
- package/src/__docs__/types.raw-scoped-cache.stories.mdx +0 -27
- package/src/__docs__/types.response-cache.stories.mdx +0 -33
- package/src/__docs__/types.result.stories.mdx +0 -39
- package/src/__docs__/types.scoped-cache.stories.mdx +0 -114
- package/src/__docs__/types.valid-cache-data.stories.mdx +0 -23
- package/src/util/gql-router-context.js +0 -6
- package/src/util/graphql-types.js +0 -30
- /package/src/hooks/__tests__/__snapshots__/{use-shared-cache.test.js.snap → use-shared-cache.test.ts.snap} +0 -0
- /package/src/util/__tests__/__snapshots__/{scoped-in-memory-cache.test.js.snap → scoped-in-memory-cache.test.ts.snap} +0 -0
- /package/src/util/__tests__/__snapshots__/{serializable-in-memory-cache.test.js.snap → serializable-in-memory-cache.test.ts.snap} +0 -0
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
|
|
3
|
-
<Meta
|
|
4
|
-
title="Data / Exports / Status"
|
|
5
|
-
parameters={{
|
|
6
|
-
chromatic: {
|
|
7
|
-
disableSnapshot: true,
|
|
8
|
-
},
|
|
9
|
-
}}
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
# Status
|
|
13
|
-
|
|
14
|
-
Provides a helper API for creating [`Result<TData>`](/docs/data-types-result--page) instances with specific statuses.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## loading()
|
|
18
|
-
|
|
19
|
-
`Status.loading()` creates a result with the `"loading"` status.
|
|
20
|
-
|
|
21
|
-
## aborted()
|
|
22
|
-
|
|
23
|
-
`Status.aborted()` creates a result with the `"aborted"` status.
|
|
24
|
-
|
|
25
|
-
## success()
|
|
26
|
-
|
|
27
|
-
`Status.success()` creates a result with the `"success"` status and the given data.
|
|
28
|
-
|
|
29
|
-
## error()
|
|
30
|
-
|
|
31
|
-
`Status.error()` creates a result with the `"error"` status and the given error.
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
import {TrackData} from "../index.js";
|
|
3
|
-
|
|
4
|
-
<Meta
|
|
5
|
-
title="Data / Exports / TrackData"
|
|
6
|
-
component={TrackData}
|
|
7
|
-
parameters={{
|
|
8
|
-
chromatic: {
|
|
9
|
-
disableSnapshot: true,
|
|
10
|
-
},
|
|
11
|
-
}}
|
|
12
|
-
/>
|
|
13
|
-
|
|
14
|
-
# TrackData
|
|
15
|
-
|
|
16
|
-
The `TrackData` component is a server-side only component. It should be used as
|
|
17
|
-
a parent to the components whose data requests you want to fulfill during
|
|
18
|
-
server-side rendering.
|
|
19
|
-
|
|
20
|
-
#### Client-side behavior
|
|
21
|
-
|
|
22
|
-
If used outside of server-side mode (as set using `Server.setServerSide`), this
|
|
23
|
-
component will throw, as demonstrated below.
|
|
24
|
-
|
|
25
|
-
```jsx
|
|
26
|
-
import {Body, BodyMonospace} from "@khanacademy/wonder-blocks-typography";
|
|
27
|
-
import {Server, View} from "@khanacademy/wonder-blocks-core";
|
|
28
|
-
import {TrackData} from "@khanacademy/wonder-blocks-data";
|
|
29
|
-
|
|
30
|
-
class ErrorBoundary extends React.Component {
|
|
31
|
-
constructor(props) {
|
|
32
|
-
super(props);
|
|
33
|
-
this.state = {};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static getDerivedStateFromError(error) {
|
|
37
|
-
return {error: error.message};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
render() {
|
|
41
|
-
if (typeof jest !== "undefined") {
|
|
42
|
-
/**
|
|
43
|
-
* The snapshot test just sees the error getting thrown, not the
|
|
44
|
-
* awesome error boundary, so we have to hack around it to keep
|
|
45
|
-
* this live example, but not get test failures.
|
|
46
|
-
*/
|
|
47
|
-
return "Sorry, no snapshot for you";
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (this.state.error) {
|
|
51
|
-
return (
|
|
52
|
-
<View>
|
|
53
|
-
{this.state.error}
|
|
54
|
-
</View>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
return this.props.children;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
<ErrorBoundary>
|
|
62
|
-
<View>
|
|
63
|
-
<TrackData>
|
|
64
|
-
<Body>This only renders if we're in server-side mode and the page hot reloaded</Body>
|
|
65
|
-
</TrackData>
|
|
66
|
-
</View>
|
|
67
|
-
</ErrorBoundary>
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
#### Server-side behavior
|
|
71
|
-
|
|
72
|
-
When used server-side, this component tracks any data requests made through
|
|
73
|
-
the `Data` component during a render cycle. This data can then be obtained
|
|
74
|
-
using the `fetchTrackedRequests` method. The data can then be used in an
|
|
75
|
-
additional render cycle to render with that data.
|
|
76
|
-
|
|
77
|
-
```jsx
|
|
78
|
-
import {Body, BodyMonospace} from "@khanacademy/wonder-blocks-typography";
|
|
79
|
-
import {Strut} from "@khanacademy/wonder-blocks-layout";
|
|
80
|
-
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
81
|
-
import Button from "@khanacademy/wonder-blocks-button";
|
|
82
|
-
import {Server, View} from "@khanacademy/wonder-blocks-core";
|
|
83
|
-
import {Data, TrackData, fetchTrackedRequests} from "@khanacademy/wonder-blocks-data";
|
|
84
|
-
|
|
85
|
-
const myPretendHandler = () => new Promise((resolve, reject) =>
|
|
86
|
-
setTimeout(() => resolve("DATA!"), 3000),
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
class Example extends React.Component {
|
|
90
|
-
constructor() {
|
|
91
|
-
super();
|
|
92
|
-
/**
|
|
93
|
-
* For this demonstration, we need to hack the return of isServerSide solely
|
|
94
|
-
* for the scope of this component.
|
|
95
|
-
*/
|
|
96
|
-
this.state = {};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static getDerivedStateFromError(error) {
|
|
100
|
-
return {error};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
componentDidMount() {
|
|
104
|
-
this._mounted = true;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
componentWillUnmount() {
|
|
108
|
-
this._mounted = false;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
setClientMode() {
|
|
112
|
-
window.location.reload();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
setServerMode() {
|
|
116
|
-
Server.setServerSide();
|
|
117
|
-
this.setState({refresh: Date.now(), error: null});
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
_renderErrorOrContent() {
|
|
121
|
-
if (typeof jest !== "undefined") {
|
|
122
|
-
/**
|
|
123
|
-
* The snapshot test just sees the error getting thrown, not the
|
|
124
|
-
* awesome error boundary, so we have to hack around it to keep
|
|
125
|
-
* this live example, but not get test failures.
|
|
126
|
-
*/
|
|
127
|
-
return "Sorry, no snapshot for you";
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (this.state.error) {
|
|
131
|
-
return (
|
|
132
|
-
<React.Fragment>
|
|
133
|
-
<Strut size={Spacing.small_12} />
|
|
134
|
-
<Body>We can't show you anything useful in client-side mode</Body>
|
|
135
|
-
</React.Fragment>
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const data = this.state.data
|
|
140
|
-
? JSON.stringify(this.state.data, undefined, " ")
|
|
141
|
-
: "Data requested...";
|
|
142
|
-
|
|
143
|
-
return (
|
|
144
|
-
<React.Fragment>
|
|
145
|
-
<Strut size={Spacing.small_12} />
|
|
146
|
-
<TrackData>
|
|
147
|
-
<Data handler={myPretendHandler} requestId="TRACK_DATA_EXAMPLE">
|
|
148
|
-
{(result) => (
|
|
149
|
-
<View>
|
|
150
|
-
<BodyMonospace>{`Loading: ${result.status === "loading"}`}</BodyMonospace>
|
|
151
|
-
<BodyMonospace>{`Data: ${JSON.stringify(result.data)}`}</BodyMonospace>
|
|
152
|
-
</View>
|
|
153
|
-
)}
|
|
154
|
-
</Data>
|
|
155
|
-
</TrackData>
|
|
156
|
-
<Strut size={Spacing.small_12} />
|
|
157
|
-
<View>
|
|
158
|
-
<Body>
|
|
159
|
-
The above components requested data, but we're server-side,
|
|
160
|
-
so all that happened is we tracked the request.
|
|
161
|
-
In this example, we've also called `fetchTrackedRequests`
|
|
162
|
-
to fetch that tracked data.
|
|
163
|
-
</Body>
|
|
164
|
-
<Strut size={Spacing.small_12} />
|
|
165
|
-
<Body>
|
|
166
|
-
In about 3 seconds, it will appear below. Notice that
|
|
167
|
-
when it does, the above still doesn't update. That's
|
|
168
|
-
because during SSR, the data is not updated in the
|
|
169
|
-
rendered tree.
|
|
170
|
-
</Body>
|
|
171
|
-
<Strut size={Spacing.small_12} />
|
|
172
|
-
<BodyMonospace>{data}</BodyMonospace>
|
|
173
|
-
</View>
|
|
174
|
-
</React.Fragment>
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
render() {
|
|
179
|
-
try {
|
|
180
|
-
return (
|
|
181
|
-
<View key={this.state.refresh}>
|
|
182
|
-
{Server.isServerSide()
|
|
183
|
-
? (
|
|
184
|
-
<React.Fragment>
|
|
185
|
-
<Button kind={"secondary"} onClick={() => this.setClientMode()}>Back to Client-side Mode (reloads page)</Button>
|
|
186
|
-
<Strut size={Spacing.small_12} />
|
|
187
|
-
<Button kind={"secondary"} onClick={() => this.setServerMode()}>Re-mount</Button>
|
|
188
|
-
</React.Fragment>
|
|
189
|
-
) : (
|
|
190
|
-
<Button kind={"primary"} onClick={() => this.setServerMode()}>Enable Server-side Mode</Button>
|
|
191
|
-
)
|
|
192
|
-
}
|
|
193
|
-
{this._renderErrorOrContent()}
|
|
194
|
-
</View>
|
|
195
|
-
);
|
|
196
|
-
} finally {
|
|
197
|
-
if (!this.state.data && Server.isServerSide()) {
|
|
198
|
-
setTimeout(() => fetchTrackedRequests().then((data) => {
|
|
199
|
-
if (this._mounted) {
|
|
200
|
-
this.setState({data});
|
|
201
|
-
}
|
|
202
|
-
}), 0);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
<Example />
|
|
209
|
-
```
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
|
|
3
|
-
<Meta
|
|
4
|
-
title="Data / Exports / useCachedEffect()"
|
|
5
|
-
parameters={{
|
|
6
|
-
chromatic: {
|
|
7
|
-
disableSnapshot: true,
|
|
8
|
-
},
|
|
9
|
-
}}
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
# useCachedEffect()
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
function useCachedEffect<TData: ValidCacheData>(
|
|
16
|
-
requestId: string,
|
|
17
|
-
handler: () => Promise<TData>,
|
|
18
|
-
options?: CachedEffectOptions<TData>,
|
|
19
|
-
): [Result<TData>, () => void];
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
This hook invokes the given handler and caches the result using the [`useSharedCache`](/docs/data-exports-usesharedcache--page) hook. The `requestId` is used to both identify inflight requests that can be shared, and to identify the cached value to use.
|
|
23
|
-
|
|
24
|
-
The hook returns an array containing the current state of the request, and a function that can be used to `refetch` that request on demand. Calling `refetch` while an inflight request is in progress for the given `requestId` will be a no-op.
|
|
25
|
-
|
|
26
|
-
The behavior of the hook can be modified with the options.
|
|
27
|
-
|
|
28
|
-
```ts
|
|
29
|
-
type CachedEffectOptions<TData: ValidCacheData> = {|
|
|
30
|
-
skip?: boolean,
|
|
31
|
-
retainResultOnChange?: boolean,
|
|
32
|
-
onResultChanged?: (result: Result<TData>) => void,
|
|
33
|
-
scope?: string,
|
|
34
|
-
fetchPolicy?: FetchPolicy,
|
|
35
|
-
|};
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
| Option | Default | Description |
|
|
39
|
-
| ------ | ------- | ----------- |
|
|
40
|
-
| `skip` | `false` | When `true`, the effect will not be executed; otherwise, the effect will be executed. If this is set to `true` while the effect is still pending, the pending effect will be cancelled. |
|
|
41
|
-
| `retainResultOnChange` | `false` | When `true`, the effect will not reset the result to the loading status while executing if the requestId changes, instead, returning the existing result from before the change; otherwise, the result will be set to loading status. If the status is loading when the changes are made, it will remain as loading; old pending effects are discarded on changes and as such this value has no effect in that case.|
|
|
42
|
-
| `onResultChanged` | `undefined` | Callback that is invoked if the result for the given hook has changed. When defined, the hook will invoke this callback whenever it has reason to change the result and will not otherwise affect component rendering directly. When not defined, the hook will ensure the component re-renders to pick up the latest result. |
|
|
43
|
-
| `scope` | `"useCachedEffect"` | Scope to use with the shared cache. When specified, the given scope will be used to isolate this hook's cached results. Otherwise, the default scope will be used. Changing this value after the first call is not supported. |
|
|
44
|
-
| `fetchPolicy` | [`FetchPolicy`](/docs/data-types-fetchpolicy--page) | Fetch policy to use when fetching the data. Defaults to `FetchPolicy.CacheBeforeNetwork`. |
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
|
|
3
|
-
<Meta
|
|
4
|
-
title="Data / Exports / useGql()"
|
|
5
|
-
parameters={{
|
|
6
|
-
chromatic: {
|
|
7
|
-
disableSnapshot: true,
|
|
8
|
-
},
|
|
9
|
-
}}
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
# useGql()
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
type FetchFn = <TData, TVariables: {...}>(
|
|
16
|
-
operation: GqlOperation<TData, TVariables>,
|
|
17
|
-
options?: GqlFetchOptions<TVariables, TContext>,
|
|
18
|
-
) => Promise<TData>;
|
|
19
|
-
|
|
20
|
-
function useGql<TContext: GqlContext>(
|
|
21
|
-
context: Partial<TContext> = ({}: $Shape<TContext>),
|
|
22
|
-
): FetchFn;
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
The `useGql` hook requires that the calling component has been rendered with a [`GqlRouter`](/docs/data-exports-gqlrouter--page) as an ancestor component since it relies on the default context and fetch operation that is specified therein.
|
|
26
|
-
|
|
27
|
-
The `useGql` hook can take a partial context value which will be combined with the default context to create the context used for a specific request.
|
|
28
|
-
|
|
29
|
-
The return value of `useGql` is a fetch function that can be used to invoke a GraphQL request. It takes as arguments the [`GqlOperation`](/docs/data-types-gqloperation--page) operation to be performed and some options (which, by their nature, are optional). These options can be used to provide variables for the operation as well as additional customization of the context.
|
|
30
|
-
|
|
31
|
-
The result of calling the function returned by `useGql` is a promise of the data that the request will return. This is compatible with the [`useServerEffect`](/docs/data-exports-useservereffect--page), [`useCachedEffect`](/docs/data-exports-usecachedeffect--page), and [`useHydratableEffect`](/docs/data-exports-usehydratableeffect--page) hooks, allowing a variety of scenarios to be easily constructed.
|
|
32
|
-
|
|
33
|
-
Use [`getGqlRequestId`](/docs/data-exports-getgqlrequestid--page) to get a request ID that can be used with these hooks.
|
|
34
|
-
|
|
35
|
-
## Context Merging
|
|
36
|
-
|
|
37
|
-
Context overrides are combined such that any values that are explicitly or implicitly `undefined` on the partial context will be ignored. Any values that are explicitly `null` on the partial context will be removed from the merged context. The order of precedence is as follows:
|
|
38
|
-
|
|
39
|
-
1. Values from the fetch partial context, then,
|
|
40
|
-
2. Values from the `useGql` partial context, then,
|
|
41
|
-
3. Values from the default context.
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
|
|
3
|
-
<Meta
|
|
4
|
-
title="Data / Exports / useHydratableEffect()"
|
|
5
|
-
parameters={{
|
|
6
|
-
chromatic: {
|
|
7
|
-
disableSnapshot: true,
|
|
8
|
-
},
|
|
9
|
-
}}
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
# useHydratableEffect()
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
function useHydratableEffect<TData: ValidCacheData>(
|
|
16
|
-
requestId: string,
|
|
17
|
-
handler: () => Promise<TData>,
|
|
18
|
-
options?: HydratableEffectOptions<TData>,
|
|
19
|
-
): Result<TData>;
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
This hook combines [`useServerEffect`](/docs/data-exports-useservereffect--page) and [`useCachedEffect`](/docs/data-exports-usecachedeffect--page) to form an effect that can execute on the server and hydrate on the client.
|
|
23
|
-
|
|
24
|
-
More details about server-side rendering with Wonder Blocks Data can be found in the [relevant overview section](/docs/data-server-side-rendering-and-hydration--page).
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
type HydratableEffectOptions<TData: ValidCacheData> = {|
|
|
29
|
-
clientBehavior?: WhenClientSide,
|
|
30
|
-
skip?: boolean,
|
|
31
|
-
retainResultOnChange?: boolean,
|
|
32
|
-
onResultChanged?: (result: Result<TData>) => void,
|
|
33
|
-
scope?: string,
|
|
34
|
-
|};
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
| Option | Default | Description |
|
|
38
|
-
| ------ | ------- | ----------- |
|
|
39
|
-
| `clientBehavior` | [`WhenClientSide.ExecuteWhenNoSuccessResult`](/docs/data-exports-whenclientside--page#whenclientsideexecutewhennosuccessresult) | How the hook should behave when rendering client-side for the first time. This controls the hydration and execution of the effect on the client. Changing this value after the initial render is inert. For more information on other behaviors, see [`WhenClientSide`](/docs/data-exports-whenclientside--page). |
|
|
40
|
-
| `skip` | `false` | When `true`, the effect will not be executed; otherwise, the effect will be executed. If this is set to `true` while the effect is still pending, the pending effect will be cancelled. |
|
|
41
|
-
| `retainResultOnChange` | `false` | When `true`, the effect will not reset the result to the loading status while executing if the requestId changes, instead, returning the existing result from before the change; otherwise, the result will be set to loading status. If the status is loading when the changes are made, it will remain as loading; old pending effects are discarded on changes and as such this value has no effect in that case.|
|
|
42
|
-
| `onResultChanged` | `undefined` | Callback that is invoked if the result for the given hook has changed. When defined, the hook will invoke this callback whenever it has reason to change the result and will not otherwise affect component rendering directly. When not defined, the hook will ensure the component re-renders to pick up the latest result. |
|
|
43
|
-
| `scope` | `"useCachedEffect"` | Scope to use with the shared cache. When specified, the given scope will be used to isolate this hook's cached results. Otherwise, the default scope will be used. Changing this value after the first call is not supported. |
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
|
|
3
|
-
<Meta
|
|
4
|
-
title="Data / Exports / useServerEffect()"
|
|
5
|
-
parameters={{
|
|
6
|
-
chromatic: {
|
|
7
|
-
disableSnapshot: true,
|
|
8
|
-
},
|
|
9
|
-
}}
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
# useServerEffect()
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
function useServerEffect<TData: ValidCacheData>(
|
|
16
|
-
requestId: string,
|
|
17
|
-
handler: () => Promise<TData>,
|
|
18
|
-
options?: ServerEffectOptions,
|
|
19
|
-
): ?Result<TData>;
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
The `useServerEffect` hook is an integral part of server-side rendering. It has different behavior depending on whether it is running on the server (and in what context) or the client.
|
|
23
|
-
|
|
24
|
-
```ts
|
|
25
|
-
type ServerEffectOptions = {|
|
|
26
|
-
skip?: boolean,
|
|
27
|
-
hydrate?: boolean,
|
|
28
|
-
|};
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
| Option | Default | Description |
|
|
32
|
-
| ------ | ------- | ----------- |
|
|
33
|
-
| `hydrate` | `true` | When `true`, the result of the effect when fulfilled using Wonder Blocks Data will be stored in the hydration cache for hydrating client-side; otherwise, the result will be stored in the server-side-only cache. |
|
|
34
|
-
| `skip` | `false` | When `true`, the effect will not be tracked for fulfillment; otherwise, the effect will be tracked for fulfillment. |
|
|
35
|
-
|
|
36
|
-
## Server-side behavior
|
|
37
|
-
|
|
38
|
-
First, this hook checks the server-side rendering cache for the request identifier; if it finds a cached value, it will return that.
|
|
39
|
-
|
|
40
|
-
If there is no cached value, it will return a "loading" state. In addition, if the current rendering component has a [`TrackData`](/docs/data-exports-trackdata--page) ancestor, `useServerEffect` will register the request for fulfillment.
|
|
41
|
-
|
|
42
|
-
This then allows that pending request to be fulfilled with [`fetchTrackedRequests`](/docs/data-exports-fetchtrackddatarequests--page), the response to be placed into the cache, and the render to be reexecuted, at which point, this hook will be able to provide that result instead of "loading.
|
|
43
|
-
|
|
44
|
-
More details about server-side rendering with Wonder Blocks Data can be found in the [relevant overview section](/docs/data-server-side-rendering-and-hydration--page).
|
|
45
|
-
|
|
46
|
-
## Client-side behavior
|
|
47
|
-
|
|
48
|
-
On initial render in the client, this hook will look for a corresponding value in the Wonder Blocks Data hydration cache. If there is one, it will delete it from the hydration cache and return that value.
|
|
49
|
-
|
|
50
|
-
Otherwise, it will return `null`.
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
|
|
3
|
-
<Meta
|
|
4
|
-
title="Data / Exports / useSharedCache()"
|
|
5
|
-
parameters={{
|
|
6
|
-
chromatic: {
|
|
7
|
-
disableSnapshot: true,
|
|
8
|
-
},
|
|
9
|
-
}}
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
# useSharedCache()
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
function useSharedCache<TValue: ValidCacheData>(
|
|
16
|
-
id: string,
|
|
17
|
-
scope: string,
|
|
18
|
-
initialValue?: ?TValue | (() => ?TValue),
|
|
19
|
-
): [?TValue, CacheValueFn<TValue>];
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
The `useSharedCache` hook provides access to a shared in-memory cache. This cache is not part of the cache hydrated by Wonder Blocks Data, so [`SharedCache.purgeAll()`](/docs/data-exports-sharedcache--page) must be called between server-side render cycles.
|
|
23
|
-
|
|
24
|
-
The hook returns a tuple of the currently cached value, or `null` if none is cached, and a function that can be used to set the cached value.
|
|
25
|
-
|
|
26
|
-
The shared cache is passive and as such does not notify of changes to its contents.
|
|
27
|
-
|
|
28
|
-
Each cached item is identified by an id and a scope. The scope is used to group items. Whole scopes can be cleared by specifying the specific scope when calling [`SharedCache.purgeScope()`](/docs/data-exports-sharedcache--page).
|
|
29
|
-
|
|
30
|
-
An optional argument, `initialValue` can be given. This can be either the value to be cached itself or a function that returns the value to be cached (functions themselves are not valid cachable values). This allows for expensive initialization to only occur when it is necessary.
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
|
|
3
|
-
<Meta
|
|
4
|
-
title="Data / Exports / WhenClientSide"
|
|
5
|
-
parameters={{
|
|
6
|
-
chromatic: {
|
|
7
|
-
disableSnapshot: true,
|
|
8
|
-
},
|
|
9
|
-
}}
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
# WhenClientSide
|
|
13
|
-
|
|
14
|
-
This enumeration is used with [`useHydratableEffect`](/docs/data-exports-usehydratableeffect--page). It defines how the hook should behave when rendering on the client.
|
|
15
|
-
|
|
16
|
-
## WhenClientSide.DoNotHydrate
|
|
17
|
-
|
|
18
|
-
The effect will not be hydrated and as such the effect will always be executed on initial render in the client. This is an advanced use-case that you should avoid unless you are certain of what you are doing.
|
|
19
|
-
|
|
20
|
-
Without hydration support to ensure the data is available for hydration on the client, your server and client rendered pages may differ and the hydration will fail. This option is useful if something else is responsible for data capture and hydration of the action that gets executed. For example, if the action uses Apollo Client to perform the asynchronous action executed by this effect, then that may be also performing hydration responsibilities. However, be cautious; the code that calls `useHydratableEffect` will have to have access to that data on hydration as `useHydratableEffect` will return a "loading" state on initial render, which is not what you will want.
|
|
21
|
-
|
|
22
|
-
## WhenClientSide.ExecuteWhenNoResult
|
|
23
|
-
|
|
24
|
-
On initial render in the client, the effect is hydrated from the server-side rendered result. However, it is only executed if there was no server-side render result to hydrate (this can happen if the server-side rendered request was aborted, or if the component is rendering for the first time on the client and was never part of the server-side rendered content).
|
|
25
|
-
|
|
26
|
-
## WhenClientSide.ExecuteWhenNoSuccessResult
|
|
27
|
-
|
|
28
|
-
This behavior will hydrate the server-side result, but it will only execute the effect on the client if the hydrated result is not a success result.
|
|
29
|
-
|
|
30
|
-
## WhenClientSide.AlwaysExecute
|
|
31
|
-
|
|
32
|
-
When the effect is executed with this behavior, the server-side result will be hydrated and the effect will be executed on the initial client-side render, regardless of the hydrated result status.
|
|
33
|
-
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
|
|
3
|
-
<Meta
|
|
4
|
-
title="Data / Types / CachedResponse<>"
|
|
5
|
-
parameters={{
|
|
6
|
-
chromatic: {
|
|
7
|
-
disableSnapshot: true,
|
|
8
|
-
},
|
|
9
|
-
}}
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
# CachedResponse<>
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
type CachedResponse<TData: ValidCacheData> =
|
|
16
|
-
| {|
|
|
17
|
-
+error: string,
|
|
18
|
-
+data?: void,
|
|
19
|
-
|}
|
|
20
|
-
| {|
|
|
21
|
-
+data: TData,
|
|
22
|
-
+error?: void,
|
|
23
|
-
|};
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
`CachedResponse<>` is a special union type that is used to represent the serialized result of a request, which can be used by Wonder Blocks Data to
|
|
27
|
-
hydrate the response.
|
|
28
|
-
|
|
29
|
-
See the section on [server-side rendering](/docs/data-server-side-rendering-and-hydration--page) for more information.
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
|
|
3
|
-
<Meta
|
|
4
|
-
title="Data / Types / ErrorOptions"
|
|
5
|
-
parameters={{
|
|
6
|
-
chromatic: {
|
|
7
|
-
disableSnapshot: true,
|
|
8
|
-
},
|
|
9
|
-
}}
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
# ErrorOptions
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
type ErrorOptions = {|
|
|
16
|
-
metadata?: ?Metadata,
|
|
17
|
-
cause?: ?Error,
|
|
18
|
-
|};
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
These options allow for the provision of a causal error instance as well as additional metadata that may be useful to the specific error being constructed (such as [`DataError`](/docs/data-exports-dataerror--page) or [`GqlError`](/docs/data-exports-gqlerror--page)).
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
|
|
3
|
-
<Meta
|
|
4
|
-
title="Data / Types / FetchPolicy"
|
|
5
|
-
parameters={{
|
|
6
|
-
chromatic: {
|
|
7
|
-
disableSnapshot: true,
|
|
8
|
-
},
|
|
9
|
-
}}
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
# FetchPolicy
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
export enum FetchPolicy {
|
|
16
|
-
/**
|
|
17
|
-
* If the data is in the cache, return that; otherwise, fetch from the server.
|
|
18
|
-
*/
|
|
19
|
-
CacheBeforeNetwork,
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* If the data is in the cache, return that; always fetch from the server
|
|
23
|
-
* regardless of cache.
|
|
24
|
-
*/
|
|
25
|
-
CacheAndNetwork,
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* If the data is in the cache, return that; otherwise, do nothing.
|
|
29
|
-
*/
|
|
30
|
-
CacheOnly,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Ignore any existing cached result; fetch from the server.
|
|
34
|
-
*/
|
|
35
|
-
NetworkOnly,
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
The `FetchPolicy` type is used with our request framework to define how a request should be fulfilled with respect to the cache and the network.
|
|
40
|
-
|
|
41
|
-
* `CacheBeforeNetwork`: If the data is in the cache, return that; otherwise, fetch from the server.
|
|
42
|
-
* `CacheAndNetwork`: If the data is in the cache, return that; always fetch from the server regardless of cache.
|
|
43
|
-
* `CacheOnly`: If the data is in the cache, return that; otherwise, do nothing.
|
|
44
|
-
* `NetworkOnly`: Ignore any existing cached result; always fetch from the server.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
|
|
3
|
-
<Meta
|
|
4
|
-
title="Data / Types / GqlContext"
|
|
5
|
-
parameters={{
|
|
6
|
-
chromatic: {
|
|
7
|
-
disableSnapshot: true,
|
|
8
|
-
},
|
|
9
|
-
}}
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
# GqlContext
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
type GqlContext = {|
|
|
16
|
-
[key: string]: string,
|
|
17
|
-
|};
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
`GqlContext` represents the valid range of values for the `context` of a GraphQL query or mutation.
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
|
|
3
|
-
<Meta
|
|
4
|
-
title="Data / Types / GqlFetchFn<>"
|
|
5
|
-
parameters={{
|
|
6
|
-
chromatic: {
|
|
7
|
-
disableSnapshot: true,
|
|
8
|
-
},
|
|
9
|
-
}}
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
# GqlFetchFn<>
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
type GqlFetchFn<TData, TVariables: {...}, TContext: GqlContext> = (
|
|
16
|
-
operation: GqlOperation<TData, TVariables>,
|
|
17
|
-
variables: ?TVariables,
|
|
18
|
-
context: TContext,
|
|
19
|
-
) => Promise<Response>;
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
The `GqlFetchFn<>` type describes the function that will perform a GraphQL request. A function that fits this signature is configured in Wonder Blocks Data using the [`GqlRouter`](/docs/data-exports-gqlrouter--page) component. The [`useGql`](/docs/data-exports-usegql--page) hook and derivatives are then built on top of this to abstract away complexities, such as converting the `Response` to a valid [`Result<>`](/docs/data-types-result--page) instance, as various use cases see fit.
|
|
23
|
-
|
|
24
|
-
See the section on [GraphQL](/docs/data-graphql--page) for more information.
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {Meta} from "@storybook/addon-docs";
|
|
2
|
-
|
|
3
|
-
<Meta
|
|
4
|
-
title="Data / Types / GqlFetchOptions<>"
|
|
5
|
-
parameters={{
|
|
6
|
-
chromatic: {
|
|
7
|
-
disableSnapshot: true,
|
|
8
|
-
},
|
|
9
|
-
}}
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
# GqlFetchOptions<>
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
type GqlFetchOptions<TVariables: {...}, TContext: GqlContext> = {|
|
|
16
|
-
variables?: TVariables,
|
|
17
|
-
context?: Partial<TContext>,
|
|
18
|
-
|};
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
This type describes optional configuration to apply when fulfilling a GraphQL request.
|
|
22
|
-
|
|
23
|
-
See the section on [GraphQL](/docs/data-graphql--page) for more information.
|
|
24
|
-
|