-
in the documentation, there is a for example,
I am bit confusing which ID I should use in frontend. global id or database id? resolve: (root) => {
const globalId = encodeGlobalID('Post', root.id)
return '/post/' + globalId
} it this is the correct way which is a breaking change because all my post urls have changed. also, the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Global IDs are a concept from relay. The idea is to create an id that can be resolved to a specific node without additional context. In practice this usually means a global is encoded as a combination of the type name and a unique ID. This is primarily used by the node and nodes fields. These fields accept global IDs and return the corresponding nodes. The relay client uses this for directly fetching specific nodes. Most commonly this is done when loading a new page of a connection. If a connection isn't a root query field, it is assumed to be more efficient to directly reload the parent object of the connection (assuming it is a relay node) and use that to query another page of th connection, than it would be to re-create the entire original query with all of its nested selections. Global IDs can be useful if you want to expose IDs that can be used with the node/nodes fields. You can also create globalID arguments that Pothos decodes automatically instead of using an id argument and manually deciding it. |
Beta Was this translation helpful? Give feedback.
Global IDs are a concept from relay. The idea is to create an id that can be resolved to a specific node without additional context. In practice this usually means a global is encoded as a combination of the type name and a unique ID. This is primarily used by the node and nodes fields. These fields accept global IDs and return the corresponding nodes. The relay client uses this for directly fetching specific nodes. Most commonly this is done when loading a new page of a connection. If a connection isn't a root query field, it is assumed to be more efficient to directly reload the parent object of the connection (assuming it is a relay node) and use that to query another page of th connec…