View Source Components

Mix.install([
  {:github_graphql_smartcell, "~> 0.1.0"}
])

usage

Usage

In addition to LiveBook you will need

  1. A GitHub personal access token
  2. 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.

  1. The query must define $first: Int and $after: String variables
  2. The query must use the $first and $after variables
  3. 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.