Design versions should not have duplicate ids and have version included in id
Summary
We're having duplicate IDs for different versions of same design, which results in frontend issues
From GraphQL spec:
ID: The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache.
Our frontend (Apollo-Client) uses ID of entities to maintain it's cache:
By default, InMemoryCache will attempt to use the commonly found primary keys of id and _id for the unique identifier if they exist along with __typename on an object.
Consider following query (sorry, local environment):
{
project(fullPath: "h5bp/html5-boilerplate") {
issue(iid: "10") {
designs {
designs(atVersion: "gid://gitlab/DesignManagement::Version/6") {
edges {
node {
id
image
}
}
}
}
}
}
}
We will have result (irrelevant parts skipped):
...
"node": {
"id": "gid://gitlab/DesignManagement::Design/1",
"image": "http://localhost:3001/h5bp/html5-boilerplate/-/designs/1/7c4bd1f5483ae10fe711b2ca62e562b52bb1978e"
}
...
Updating atVersion
to gid://gitlab/DesignManagement::Version/5
will result in following response:
...
"node": {
"id": "gid://gitlab/DesignManagement::Design/1",
"image": "http://localhost:3001/h5bp/html5-boilerplate/-/designs/1/f1986e5bdd8349aaf69149accbf9748c9b90983e"
}
...
(different image hash)
At this point caching layer at frontend will treat this response as "aha, update entry with id gid://gitlab/DesignManagement::Design/1
" and will return latter image
no matter which version we're requesting
Suggested fix:
- Include version id for design
The solution for this is to include a new type, DesignAtVersion
, which represents a design as of a particular version. These can be discovered at VersionType.designsAtVersion
, and then retrieved either from that version, or from the IssueType.designCollection.designAtVersion(id: id)
.
/cc @.luke @alexkalderimis for visibility