View Source GitHub.GraphQL (GitHub GraphQL Smart Cell v0.1.0)

Link to this section Summary

Functions

Make a paginated query against the GitHub GraphQL API

Query the GitHub GraphQL API

Link to this section Functions

Link to this function

paginate(query, config, vars \\ %{first: 20})

View Source

Make a paginated query against the GitHub GraphQL API

This requires that the query itself support pagination.

  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 }

example-query-that-supports-automatic-pagination

Example query that supports automatic pagination

query($first: Int, $after: String) {
  viewer {
    followers(first: $first, after: $after) {
      pageInfo {
        endCursor
        hasNextPage
      }
      nodes {
        databaseId
      }
    }
  }
}

The nodes data will be collected into a list and returned.

Link to this function

query(query, config, vars \\ %{first: 20})

View Source

Query the GitHub GraphQL API

Nothing fancy here like GitHub.GraphQL.paginate: the query is simply submitted and the response lightly parsed.

The happy path is a response with a 200 status code and a body that contains a "data" field. If this is the case then {:ok, data} is returned.

Otherwise various well known error conditions are recognized and will be returned as {:error, some_error_value}