https://facebook.github.io/relay/graphql/objectidentification.htm is very clear around what Node
is and how it behaves, but it doesn't specify which objects must implement it, or what the consequences are if your object doesn't implement it. Is there a set of features that don't work? Are such objects completely ignored? Not all objects in the existing spec (e.g. pageInfo
) implement it, so it's clearly not universally required, but pageInfo
is somewhat of a special case.
Another way of thinking about the Node
interface is that objects that implement it are refetchable. Refetchability effectively means that an object has an ID that I can use to identify the object and retrieve it; by convention, these IDs will usually be opaque, but will contain type information and an identifier within that type (eg. a Base-64 encoding of a string like "Account:1234").
Relay will leverage refetchability in two ways:
QWNjb3VudDoxMjM0
(say, the name
and address
fields), and you then navigate to a view where we show some additional fields (location
, createdAt
) then Relay can make a minimal query that "refetches" the node but only requests the missing fields.Node
interface to fill in missing data on those (example: through some combination of navigation you might have full information for some items in a view, but need to fill in location
for some items within the range, or you might modify an item in a connection via a mutation). So, in basic pagination, Relay will often end up making a first
+ after
query to extend a connection, but if you inspect its network traffic in a real app you will also see that it makes node
queries for items within connections.So yes, you're right that pageInfo
doesn't implement Node
, and it wouldn't really make sense for it to do so.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With