Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 941 Bytes

quickstart.md

File metadata and controls

40 lines (28 loc) · 941 Bytes

Octokit.GraphQL.net Quickstart

Creating a connection

The first thing you will need to do is to create a Connection with a personal access token.

For more information on creating personal access tokens, see the article

using Octokit.GraphQL;

var productInformation = new ProductHeaderValue("YOUR_PRODUCT_NAME", "YOUR_PRODUCT_VERSION");
var connection = new Connection(productInformation, YOUR_OAUTH_TOKEN);

Showing the Viewer's Username

Lets get started with a simple query that shows your username:

var query = new Query().Viewer.Select(x => x.Login);

This represents the following GraphQL query:

query {
  viewer {
    login
  }
}

To run the query, use the connection you created:

var result = await connection.Run(query);
Console.WriteLine(result.Single()); // Prints your username