Skip to content

A .NET Library for communicating with the Github API

Notifications You must be signed in to change notification settings

suny-am/github-api-dotnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Github API .NET Library

Description

A .NET Library for communicating with the Github API (only GraphQL is supported for now).

Features

  • A generic request client that enables authorized queries
  • preconfigured extendable query result types, derived from the Github GraphQL API Schema:
# Github GraphQL API schema introspection
query {
  __schema {
    types {
      name
      possibleTypes {
        ...
      }
    }
  }
}

Notes

The preconfigured types can be, and are encouraged to be extended to suit your needs. This is because the scope of the Github API makes it unfeasible to maintain preconfigured types for each type in the schema. View the existing Types as inspiration. The inheritance structure in C# makes extending and/or overriding a Type trivial.

Due to how GraphQL response namespaces work the responsetype has to match the request query:

# Example query
RepositoryConnectionFragment repoConnectionFragment = new();

string repoQuery = @"query ($orgLogin: String! $count: Int!) {
                organization(login: $orgLogin) {
                  repositories(first: $count) {
                    ... on RepositoryConnection {
                      nodes {
                        id
                        name
                      }
                    }
                  }
                }
              }
              
var variables2 = new
{
  orgLogin = "someOrgLogin",
  count = 100,
};

var request = new AuthenticatedRequest(repoQuery, variables2);

ResponseType? result = await graphQLHandler.PerformQuery(request);

# Handle Exceptions
if (result! is null)
{
  ...
}

# match the expected result Type to the request query
RepositoryListType? repositories = result2!.Organization?.Repositories;

# consume the result
Console.WriteLine(repositories.Nodes.Count());

Testing

The GithubAPI.Console project can be used to test functionality locally

Resources

Contact

visualarea.1@gmail.com

About

A .NET Library for communicating with the Github API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages