Commit d27dcf38 authored by Evan Read's avatar Evan Read

Merge branch 'lf-graphql-fe-docs-global-id' into 'master'

Add getIdFromGraphQLId to FE GraphQL docs

See merge request gitlab-org/gitlab!42408
parents 5a520d37 c09917a0
......@@ -41,7 +41,7 @@ add a `HTTP_PRIVATE_TOKEN` header.
GitLab's GraphQL API uses Global IDs (i.e: `"gid://gitlab/MyObject/123"`)
and never database primary key IDs.
Global ID is [a standard](https://graphql.org/learn/global-object-identification/)
Global ID is [a convention](https://graphql.org/learn/global-object-identification/)
used for caching and fetching in client-side libraries.
See also:
......
......@@ -141,6 +141,20 @@ fragment DesignItem on Design {
More about fragments:
[GraphQL Docs](https://graphql.org/learn/queries/#fragments)
## Global IDs
GitLab's GraphQL API expresses `id` fields as Global IDs rather than the PostgreSQL
primary key `id`. Global ID is [a convention](https://graphql.org/learn/global-object-identification/)
used for caching and fetching in client-side libraries.
To convert a Global ID to the primary key `id`, you can use `getIdFromGraphQLId`:
```javascript
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
const primaryKeyId = getIdFromGraphQLId(data.id);
```
## Immutability and cache updates
From Apollo version 3.0.0 all the cache updates need to be immutable; it needs to be replaced entirely
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment