Object Identifier
What is it
GraphQL has a built-in ID scalar type, which represents a unique identifier.
- often used to refetch an object or as the key for a
cache.
The ID type is serialized in the same way as a String
- however, defining it as an
IDsignifies that it is not intended to be human‐readable.
It is best to rely on existing libs or tool sets that provide handling of object identifiers
You can specify a unique identifier for any object you query.
- Apollo Client assumes that all objects with the same
object identifierrepresent the same piece of information.
Even if the entrypoint or the query looks different, GraphQL recognizes the queries as the same object and caches/returns it:
query { author(name: "Arthur Goldhammer") { coauthors { name id } } } query { author(id: "5") { name id } }