Components
Mix.install([
{:github_graphql_smartcell, "~> 0.1.0"}
])
Usage
In addition to Livebook you will need
- A GitHub personal access token
-
A GraphQL query you want to execute e.g.
{ viewer { name } }
In your Elixir Livebook’s setup cell either search for
github_graphql_smartcell
or add the above Mix.install
code.
Then click “+ Smart” and then select “GitHub GraphQL Query” to insert the smart cell.
A simple query to start with is to simply ask for your own username.
{ viewer { name } }
In the smart cell itself, paste in your GitHub personal access token and GraphQL query. Then execute!
You should see your query results or a reasonably useful error display.
By default queries run unpaginated, meaning that the smart cell simply executes the query as given and returns the results.
If you run the query with pagination checked then the smart cell attempts to automatically paginate through the results and collect them into a single list.
In order for pagination to work the query must conform to a set of assumptions.
-
The query must define
$first: Int
and$after: String
variables -
The query must use the
$first
and$after
variables -
The query must request
pageInfo { hasNextPage, endCursor }
A query that meets the expectations
query($first: Int, $after: String) {
viewer {
followers(first: $first, after: $after) {
pageInfo {
endCursor
hasNextPage
}
nodes {
databaseId
}
}
}
}
For more details see Pagination.