3 ms·
Why can't the ID also be a link? Serious question. I don't see any real downside to it. If the ID is also a link, it is guaranteed to be globally unique (like
by frosted-flakes 7y ago
Why can't the ID also be a link? Serious question. I don't see any real downside to it.
If the ID is also a link, it is guaranteed to be globally unique (like a Relay Node ID in GraphQL).
If you want to get the same resource via GraphQL, just use the same URL-ID. In fact, the author mentioned the possibility of base64-ing the link to prevent clients from relying on its structure, which is also a common pattern with IDs in GraphQL.
- siscia 7y agoIs not that they can't, it is just that link are not designed to be ID. The ID is the maximum cardinality of an entity (informally the smallest set of values of such entity necessary to uniquely identify it), the link is how to find the entity. What happen if you want to deprecated your API? There are other way to share the link of a resource,like use headers. Then again, from a strictly practical point of view in 99.9% of the case it won't change anything, but: 1. Eventually there will be cases where it does matter, and then it will be an huge mess. 2. Why shut yourself a door only to don't read an header and obtain exactly the same information?