Standardize use of IDs in GraphQL

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Whenever we use id within GraphQL we treat it as a Global ID.

It's encourage use of global IDs but we have some exceptions:

When exposing a model that had an internal ID (iid), prefer using that in combination with the namespace path as arguments in a resolver over a database ID. Otherwise use a globally unique ID. (https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#resolvers)

This can end up with situations where an iid is exposed in one query, but a Global ID is required for another call (or vice-versa).

An example of this is:

  • project.issues returns an iid & does not return an id.
  • addAwardEmoji expects a global ID as an argument (because some Issuable items don't have iids I beleive)

In this case you're left with an inconsistent API experience.

Can we improve on this somehow?

Ideas:

  • Make id mandatory for types that contain an ID.
  • Use iid in conjunction with project path to generate the id, if available. i.e rather than gid://app/Issue/201111 you might have gid://gitlab-org/gitlab/Issue/10. This way may be use id for everything, without exposing internal IDs for objects that don't need to.
Edited by 🤖 GitLab Bot 🤖