Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'doc/development/fe_guide/graphql.md')
-rw-r--r--doc/development/fe_guide/graphql.md30
1 files changed, 27 insertions, 3 deletions
diff --git a/doc/development/fe_guide/graphql.md b/doc/development/fe_guide/graphql.md
index 5807c9c5621..22b977519be 100644
--- a/doc/development/fe_guide/graphql.md
+++ b/doc/development/fe_guide/graphql.md
@@ -1,8 +1,7 @@
---
-type: reference, dev
stage: none
group: unassigned
-info: "See the Technical Writers assigned to Development Guidelines: https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments-to-development-guidelines"
+info: Any user with at least the Maintainer role can merge updates to this content. For details, see https://docs.gitlab.com/ee/development/development_processes.html#development-guidelines-review.
---
# GraphQL
@@ -105,7 +104,7 @@ Default client accepts two parameters: `resolvers` and `config`.
### Multiple client queries for the same object
-If you are making multiple queries to the same Apollo client object you might encounter the following error: `Cache data may be lost when replacing the someProperty field of a Query object. To address this problem, either ensure all objects of SomeEntityhave an id or a custom merge function`. We are already checking `id` presence for every GraphQL type that has an `id`, so this shouldn't be the case (unless you see this warning when running unit tests; in this case please ensure your mocked responses contain an `id` whenever it's requested).
+If you are making multiple queries to the same Apollo client object you might encounter the following error: `Cache data may be lost when replacing the someProperty field of a Query object. To address this problem, either ensure all objects of SomeEntityhave an id or a custom merge function`. We are already checking `id` presence for every GraphQL type that has an `id`, so this shouldn't be the case (unless you see this warning when running unit tests; in this case ensure your mocked responses contain an `id` whenever it's requested).
When `SomeEntity` type doesn't have an `id` property in the GraphQL schema, to fix this warning we need to define a custom merge function.
@@ -974,6 +973,31 @@ const data = store.readQuery({
Read more about the `@connection` directive in [Apollo's documentation](https://www.apollographql.com/docs/react/caching/advanced-topics/#the-connection-directive).
+### Batching similar queries
+
+By default, the Apollo client sends one HTTP request from the browser per query. You can choose to
+batch several queries in a single outgoing request and lower the number of requests by defining a
+[batchKey](https://www.apollographql.com/docs/react/api/link/apollo-link-batch-http/#batchkey).
+
+This can be helpful when a query is called multiple times from the same component but you
+want to update the UI once. In this example we use the component name as the key:
+
+```javascript
+export default {
+ name: 'MyComponent'
+ apollo: {
+ user: {
+ query: QUERY_IMPORT,
+ context: {
+ batchKey: 'MyComponent',
+ },
+ }
+ },
+};
+```
+
+The batch key can be the name of the component.
+
#### Polling and Performance
While the Apollo client has support for simple polling, for performance reasons, our [ETag-based caching](../polling.md) is preferred to hitting the database each time.