You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Signals that [GraphQL cache](#graphql-instance-property-cache) subscribers such as the [`useGraphQL`](#function-usegraphql) React hook should reload their GraphQL operation. Emits a [`GraphQL`](#class-graphql) instance `reload` event.
216
+
Signals that [GraphQL cache](#graphql-instance-property-cache) subscribers such as the [`useGraphQL`](#function-usegraphql) React hook should reload their GraphQL operation.
208
217
209
218
| Parameter | Type | Description |
210
219
| :-- | :-- | :-- |
211
220
| `exceptCacheKey` | [GraphQLCacheKey](#type-graphqlcachekey)? | A [GraphQL cache](#graphql-instance-property-cache) [key](#type-graphqlcachekey) for cache to exempt from reloading. |
212
221
222
+
##### Fires
223
+
224
+
- [GraphQL event reload](#graphql-event-reload)
225
+
213
226
##### Examples
214
227
215
228
_Reloading the [GraphQL cache](#graphql-instance-property-cache)._
@@ -220,12 +233,16 @@ _Reloading the [GraphQL cache](#graphql-instance-property-cache)._
220
233
221
234
#### GraphQL instance method reset
222
235
223
-
Resets the [GraphQL cache](#graphql-instance-property-cache), useful when a user logs out. Emits a [`GraphQL`](#class-graphql) instance `reset` event.
236
+
Resets the [GraphQL cache](#graphql-instance-property-cache), useful when a user logs out.
224
237
225
238
| Parameter | Type | Description |
226
239
| :-- | :-- | :-- |
227
240
| `exceptCacheKey` | [GraphQLCacheKey](#type-graphqlcachekey)? | A [GraphQL cache](#graphql-instance-property-cache) [key](#type-graphqlcachekey) for cache to exempt from deletion. Useful for resetting cache after a mutation, preserving the mutation cache. |
228
241
242
+
##### Fires
243
+
244
+
- [GraphQL event reset](#graphql-event-reset)
245
+
229
246
##### Examples
230
247
231
248
_Resetting the [GraphQL cache](#graphql-instance-property-cache)._
@@ -268,6 +285,49 @@ A map of loading GraphQL operations. You probably don’t need to interact with
Signals that a GraphQL operation was fetched and cached.
291
+
292
+
**Type:** object
293
+
294
+
| Property | Type | Description |
295
+
| :-- | :-- | :-- |
296
+
| `cacheKey` | [GraphQLCacheKey](#type-graphqlcachekey) | The [GraphQL cache](#graphql-instance-property-cache) [key](#type-graphqlcachekey) for the operation that was cached. |
| `response` | Response? | The [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) instance; may be undefined if there was a fetch error. |
299
+
300
+
#### GraphQL event fetch
301
+
302
+
Signals that a GraphQL operation is being fetched.
303
+
304
+
**Type:** object
305
+
306
+
| Property | Type | Description |
307
+
| :-- | :-- | :-- |
308
+
| `cacheKey` | [GraphQLCacheKey](#type-graphqlcachekey) | The [GraphQL cache](#graphql-instance-property-cache) [key](#type-graphqlcachekey) for the operation being fetched. |
Signals that [GraphQL cache](#graphql-instance-property-cache) subscribers such as the [`useGraphQL`](#function-usegraphql) React hook should reload their GraphQL operation.
314
+
315
+
**Type:** object
316
+
317
+
| Property | Type | Description |
318
+
| :-- | :-- | :-- |
319
+
| `exceptCacheKey` | [GraphQLCacheKey](#type-graphqlcachekey)? | A [GraphQL cache](#graphql-instance-property-cache) [key](#type-graphqlcachekey) for cache to exempt from reloading. |
320
+
321
+
#### GraphQL event reset
322
+
323
+
Signals that the [GraphQL cache](#graphql-instance-property-cache) has been reset.
324
+
325
+
**Type:** object
326
+
327
+
| Property | Type | Description |
328
+
| :-- | :-- | :-- |
329
+
| `exceptCacheKey` | [GraphQLCacheKey](#type-graphqlcachekey)? | The [GraphQL cache](#graphql-instance-property-cache) [key](#type-graphqlcachekey) for cache that was exempted from deletion. |
330
+
271
331
---
272
332
273
333
### function GraphQLProvider
@@ -306,13 +366,11 @@ _Provide a [`GraphQL`](#class-graphql) instance for an app._
306
366
307
367
### function reportCacheErrors
308
368
309
-
A [`GraphQL`](#class-graphql) `cache`event handler that reports [`fetch`](https://developer.mozilla.org/docs/Web/API/Fetch_API), HTTP, parse and GraphQL errors via `console.log()`. In a browser environment the grouped error details are expandable.
369
+
A [`GraphQL` event `cache`](#graphql-event-cache) handler that reports [`fetch`](https://developer.mozilla.org/docs/Web/API/Fetch_API), HTTP, parse and GraphQL errors via `console.log()`. In a browser environment the grouped error details are expandable.
Copy file name to clipboardExpand all lines: src/universal/GraphQL.js
+8-2Lines changed: 8 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -92,10 +92,11 @@ module.exports = class GraphQL {
92
92
/**
93
93
* Signals that [GraphQL cache]{@link GraphQL#cache} subscribers such as the
94
94
* [`useGraphQL`]{@link useGraphQL} React hook should reload their GraphQL
95
-
* operation. Emits a [`GraphQL`]{@link GraphQL} instance `reload` event.
95
+
* operation.
96
96
* @kind function
97
97
* @name GraphQL#reload
98
98
* @param {GraphQLCacheKey} [exceptCacheKey] A [GraphQL cache]{@link GraphQL#cache} [key]{@link GraphQLCacheKey} for cache to exempt from reloading.
99
+
* @fires GraphQL#event:reload
99
100
* @example <caption>Reloading the [GraphQL cache]{@link GraphQL#cache}.</caption>
100
101
* ```js
101
102
* graphql.reload();
@@ -107,10 +108,11 @@ module.exports = class GraphQL {
107
108
108
109
/**
109
110
* Resets the [GraphQL cache]{@link GraphQL#cache}, useful when a user logs
110
-
* out. Emits a [`GraphQL`]{@link GraphQL} instance `reset` event.
111
+
* out.
111
112
* @kind function
112
113
* @name GraphQL#reset
113
114
* @param {GraphQLCacheKey} [exceptCacheKey] A [GraphQL cache]{@link GraphQL#cache} [key]{@link GraphQLCacheKey} for cache to exempt from deletion. Useful for resetting cache after a mutation, preserving the mutation cache.
115
+
* @fires GraphQL#event:reset
114
116
* @example <caption>Resetting the [GraphQL cache]{@link GraphQL#cache}.</caption>
115
117
* ```js
116
118
* graphql.reset();
@@ -134,6 +136,8 @@ module.exports = class GraphQL {
134
136
* @param {GraphQLFetchOptions} fetchOptions URL and options for [`fetch`](https://developer.mozilla.org/docs/Web/API/Fetch_API).
* @returns {Promise<GraphQLCacheValue>} A promise that resolves the [GraphQL cache]{@link GraphQL#cache} [value]{@link GraphQLCacheValue}.
139
+
* @fires GraphQL#event:fetch
140
+
* @fires GraphQL#event:cache
137
141
* @ignore
138
142
*/
139
143
fetch=({ url, ...options},cacheKey)=>{
@@ -215,6 +219,8 @@ module.exports = class GraphQL {
215
219
* @param {boolean} [options.reloadOnLoad=false] Should a [GraphQL reload]{@link GraphQL#reload} happen after the operation loads, excluding the loaded operation cache.
216
220
* @param {boolean} [options.resetOnLoad=false] Should a [GraphQL reset]{@link GraphQL#reset} happen after the operation loads, excluding the loaded operation cache.
* Signals that [GraphQL cache]{@link GraphQL#cache} subscribers such as the
41
+
* [`useGraphQL`]{@link useGraphQL} React hook should reload their GraphQL
42
+
* operation.
43
+
* @kind event
44
+
* @name GraphQL#event:reload
45
+
* @type {object}
46
+
* @prop {GraphQLCacheKey} [exceptCacheKey] A [GraphQL cache]{@link GraphQL#cache} [key]{@link GraphQLCacheKey} for cache to exempt from reloading.
47
+
*/
48
+
49
+
/**
50
+
* Signals that the [GraphQL cache]{@link GraphQL#cache} has been reset.
51
+
* @kind event
52
+
* @name GraphQL#event:reset
53
+
* @type {object}
54
+
* @prop {GraphQLCacheKey} [exceptCacheKey] The [GraphQL cache]{@link GraphQL#cache} [key]{@link GraphQLCacheKey} for cache that was exempted from deletion.
55
+
*/
56
+
57
+
/**
58
+
* Signals that a GraphQL operation is being fetched.
59
+
* @kind event
60
+
* @name GraphQL#event:fetch
61
+
* @type {object}
62
+
* @prop {GraphQLCacheKey} cacheKey The [GraphQL cache]{@link GraphQL#cache} [key]{@link GraphQLCacheKey} for the operation being fetched.
* @prop {Response} [response] The [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) instance; may be undefined if there was a fetch error.
74
+
*/
75
+
39
76
/**
40
77
* GraphQL API URL and
41
78
* [polyfillable `fetch` options](https://github.github.io/fetch/#options). The
0 commit comments