Global Object IDs🔗
In this section, we'll cover how to add support for object refetching and client caching using the Relay Global Object Identification specification.
For Relay-compliant clients, see the Connection section
for adding support for pagination with Connections
.
Node Interface🔗
Your QueryTypes
can implement the Node
interface to add support for Global Object IDs.
This will add an id
field to the TaskType
for resolving Global Object IDs.
Note that most Django models already contain an id
field for as the primary key of the table,
and that implementing this interface will override it with the Global Object ID field. To access the
model id
field, you can use the pk
field instead.
Node Entrypoint🔗
A Global Object ID can be used for refetching objects from a special Node
Entrypoint
.
To use this Entrypoint
, we must first query the schema in some other way, for example
using the tasks
Connection Entrypoint
in the above example. Then, we can use the
fetched Global Object ID to refetch the Task
from the Node
Entrypoint
.
Note that Global Object IDs (e.g. U3Vyc29yOnVzZXJuYW1lOjE=
in the above example)
are meant to be opaque to the client, meaning they aren't supposed to know what they
contain or how to parse them.