Here is a GraphQL query to fetch my repositories
{
user(login: "Mattamorphic") {
repositories(first: 2) {
edges {
cursor
node {
name
}
}
pageInfo {
endCursor
hasNextPage
}
}
}
}
- The outer query
user(login: "Mattamorphic")
is returning a single user which is this: https://developer.github.com/v4/object/user/ - This User object has a
repositories
connection, a connection is the edge betweeen the User object (node), and the Repository object (node) - Here's a blog that explains this further https://blog.apollographql.com/explaining-graphql-connections-c48b7c3d6976
Connections have parameters that specify a way to slice the amount of edges / nodes we are returning:
first: X
limit to the first X amount of connections (created time)last: X
limnit to the last X amount of connections (created time)after: X
after the cursor (offset)
Connections return three main fields:
edges
A list of edges, composed of the fieldscursor
andnode
nodes
A list of just the nodes themselvespageInfo
An object containingendCursor
the last cursor on the current page of results,hasNextPage
a boolean (true | false) field on if there are more pages