I'm trying to batch my GraphQL queries to retrieve the data I need from multiple repositories with the same request, where each repository has a different cursor.
Assuming I have the IDs of 3 nodes and only 2 cursors with the following mapping:
NODE_ID_1 <-> CURSOR_X
NODE_ID_2 <-> Empty
Node_ID_3 <-> CURSOR_Y
How can I populate the GraphQL query so that I can query all 3 nodes, but pass their respective cursors?
query {
nodes(ids: ["NODE_ID_1", "NODE_ID_2", "NODE_ID_3"]) {
... on Repository {
databaseId
stargazers(first: 100, after:???) {
pageInfo {
endCursor
}
edges {
starredAt
}
}
}
}
}
You can use aliases by iterating over nodes and map them to a field name like
nodeX
:output:
For the cursor value you just need to map the field name to both the node id and the cursor value:
In this case your input map would look like:
With variables:
variables :