Great question, Daniel!
The structure and naming of these types follow the GraphQL Cursor Connections Specification, which aims to "consistently handle pagination best practices with support for related metadata via a GraphQL server."
While we don't currently add a lot of information on the edge types (they only contain the cursor and node fields), we envision that they will be useful for adding extra metadata in the future.
One example of metadata that belongs on the edge types is data about a relationship (edge) between two objects (nodes). Say we want to model a time-limited flow between two assets:
(a1: Asset) -- FLOWS_TO { startTime: 1648120612, endTime: 1648125620 }] → (a2: Asset)
The query could then look something like this:
{
listAsset(externalId: "a1") {
edges {
node {
externalId
flowsTo {
edges {
startTime
endTime
node {
externalId
}
}
pageinfo {
endCursor
hasNextPage
}
}
}
}
}
}
However, we have considered adding a convenience field for accessing the nodes when you don't have/need such information on the edges. This would probably look very similar to what you are suggesting:
{
listAsset() {
nodes {
externalId
...
}
pageinfo {
endCursor,
hasNextPage
}
}
}