1- # Octokit.GraphQL
1+ < h1 align = " center " > Octokit.GraphQL.NET</ h1 >
22
3- [ ![ Build status] ( https://ci.appveyor.com/api/projects/status/falhvlth7og0nkw4/branch/main?svg=true )] ( https://ci.appveyor.com/project/github-windows/octokit-graphql/branch/main )
4- [ ![ codecov] ( https://codecov.io/gh/octokit/octokit.graphql.net/branch/main/graph/badge.svg )] ( https://codecov.io/gh/octokit/octokit.graphql.net )
5- [ ![ NuGet] ( http://img.shields.io/nuget/v/Octokit.GraphQL.svg )] ( https://www.nuget.org/packages/Octokit.GraphQL )
3+ <p align =" center " >
4+ <a style =" text-decoration :none " href =" https://github.com/octokit/octokit.graphql.net/actions/workflows/dotnetcore.yml " >
5+ <img src="https://github.com/octokit/octokit.graphql.net/actions/workflows/dotnetcore.yml/badge.svg" alt="CI Status" /></a>
6+ <a style =" text-decoration :none " href =" https://codecov.io/gh/octokit/octokit.graphql.net " >
7+ <img src="https://codecov.io/gh/octokit/octokit.graphql.net/branch/main/graph/badge.svg" alt="CodeCov Status" /></a>
8+ <a style =" text-decoration :none " href =" https://www.nuget.org/packages/Octokit.GraphQL " >
9+ <img src="http://img.shields.io/nuget/v/Octokit.GraphQL.svg" alt="NuGet" /></a>
10+ </p >
611
7- ** Note ** : This software is currently beta. There are few things left, and there might be bugs - be warned!
12+ Octokit.GraphQL.NET gives you access to the GitHub GraphQL API from within the .NET Framework. It exposes the GitHub GraphQL API as a strongly-typed LINQ-like API, aiming to follow the GraphQL query syntax as closely as possible, giving the benefits of strong typing across the world's leading programming framework, .NET.
813
9- Octokit.GraphQL gives you access to the GitHub GraphQL API from .NET. It exposes the GitHub GraphQL API as a strongly-typed LINQ-like API, aiming to follow the GraphQL query syntax as closely as possible, which giving the benefits of strong typing in your favorite .NET language.
14+ > [ !NOTE]
15+ > This software is currently in beta. There are few things left, and there might be bugs - be warned!
1016
11- ## Documentation
17+ ## Getting started
1218
13- You can find our documentation [ here ] ( docs/readme.md ) .
19+ The full documentation of GraphQL API can be found on [ GitHub Docs ] ( https://docs.github.com/graphql/overview ) :
1420
15- ## Installing from Nuget
21+ - [ GraphQL public schema] ( https://docs.github.com/graphql/overview/public-schema )
22+ - [ GraphQL explorer] ( https://docs.github.com/graphql/overview/explorer )
23+ - [ Octokit.GraphQL.NET API spec] ( https://github.com/octokit/octokit.graphql.net/tree/main/docs )
1624
17- ```
25+ To install the package from the command line, run the following command:
26+
27+ ``` ps1
1828Install-Package Octokit.GraphQL -IncludePrerelease
1929```
2030
21- ## Usage Example
31+ ## Usage scenarios
2232
23- ``` csharp
33+ ``` cs
2434using Octokit .GraphQL ;
2535using static Octokit .GraphQL .Variable ;
2636
27- var productInformation = new ProductHeaderValue ( " YOUR_PRODUCT_NAME " , " YOUR_PRODUCT_VERSION " );
28- var connection = new Connection (productInformation , YOUR_OAUTH_TOKEN );
37+ // Authenticate with a PAT with a scope 'read:user'
38+ var connection = new Connection (new ( " Octokit.GraphQL.Net.SampleApp " , " 1.0 " ), " LOGGED_IN_GITHUB_USER_TOKEN " );
2939
3040var query = new Query ()
3141 .RepositoryOwner (Var (" owner" ))
@@ -50,52 +60,85 @@ var result = await connection.Run(query, vars);
5060Console .WriteLine (result .Login + " & " + result .Name + " Rocks!" );
5161```
5262
53- ``` csharp
63+ ``` cs
5464using Octokit .GraphQL ;
5565using Octokit .GraphQL .Model ;
5666using System ;
5767using System .Linq ;
5868using System .Threading .Tasks ;
5969
60- namespace Octokit
61- {
62- class Program
70+ // Authenticate with a PAT with a scope 'read:user'
71+ var connection = new Connection (new (" Octokit.GraphQL.Net.SampleApp" , " 1.0" ), " LOGGED_IN_GITHUB_USER_TOKEN" );
72+
73+ // A query to list out who you are actively sponsoring
74+ // That auto pages through all sponsors
75+ var query = new Query ()
76+ .Viewer
77+ .SponsorshipsAsSponsor ()
78+ .AllPages ()
79+ .Select (sponsoring => new
6380 {
64- static async Task Main (string [] args )
65- {
66- var productInformation = new ProductHeaderValue (" ExampleCode" , " 1.0" );
67-
68- // Personal Access Token - needs a scope of 'read:user'
69- var connection = new Connection (productInformation , " LOGGED_IN_GITHUB_USER_TOKEN" );
70-
71- // A query to list out who you are actively sponsoring
72- // That auto pages through all sponsors
73- var query = new Query ()
74- .Viewer
75- .SponsorshipsAsSponsor ()
76- .AllPages ()
77- .Select (sponsoring => new
78- {
79- User = sponsoring .Sponsorable
80- .Cast <User >()
81- .Select (x => new {
82- x .Login ,
83- x .Name ,
84- x .Id
85- })
86- .Single ()
87- })
88- .Compile ();
89-
90- var result = await connection .Run (query );
91-
92- // Sponsoring 'warrenbuckley' ?
93- var activeSponsor = result .SingleOrDefault (x => x .User .Login .ToLowerInvariant () == " warrenbuckley" );
94- if (activeSponsor != null )
81+ User = sponsoring .Sponsorable
82+ .Cast <User >()
83+ .Select (x => new
9584 {
96- Console .WriteLine (" Thanks for sponsoring Warren" );
97- }
98- }
99- }
85+ x .Login ,
86+ x .Name ,
87+ x .Id
88+ }.Single ()
89+ }).Compile ();
90+
91+ // Queries from the GraphQL API end point
92+ var result = await connection .Run (query );
93+
94+ // Check if sponsoring 'warrenbuckley'
95+ var activeSponsor = result .SingleOrDefault (x => x .User .Login .ToLowerInvariant () == " warrenbuckley" );
96+ if (activeSponsor != null )
97+ {
98+ Console .WriteLine (" Thanks for sponsoring Warren" );
10099}
101100```
101+
102+ ## Contributing & Feedback
103+
104+ There are multiple ways to participate in the community :
105+
106+ - Upvote popular feature requests
107+ - [Submit a new feature ](https :// github.com/octokit/octokit.graphql.net/pulls)
108+ - [File bugs and feature requests ](https :// github.com/octokit/octokit.graphql.net/issues/new/choose).
109+ - Review source [code changes ](https :// github.com/octokit/octokit.graphql.net/commits)
110+
111+ ## Building from source
112+
113+ ### Prerequisites
114+
115+ 1 . Ensure you have following components :
116+ - [Git ](https :// git-scm.com/)
117+ - [Visual Studio and the .NET SDK ](https :// visualstudio.microsoft.com/vs/)
118+ 2 . Clone the repository :
119+ ```git
120+ git clone https :// github.com/octokit/octokit.graphql.net
121+ ```
122+
123+ ### Building the project
124+
125+ - Open `Octokit .GraphQL .sln `.
126+ - Set the Startup Project to `Octokit .GraphQL ` or a test project as appropriate
127+ - Build with `DEBUG | x64 ` (or `DEBUG | Any CPU `)
128+
129+ ### Codebase structure
130+
131+ ```
132+ .
133+ ├──Scripts // Code quality scripts
134+ │ └──configure - integration - tests .ps1 // Integration tests configuration script
135+ ├──Tools // Code quality tools
136+ │ └──Generate // GraphQL .NET entity generator
137+ ├──Octokit .GraphQL // Main API data contracts library
138+ ├──Octokit .GraphQL .Core // Octokit core code
139+ ├──Octokit .GraphQL .Core .Generation // Core entity generator tools
140+ ├──Octokit .GraphQL .Core .Generation .UnitTests // Core entity generator unit tests
141+ ├──Octokit .GraphQL .Core .UnitTests // Octokit core unit tests
142+ ├──Octokit .GraphQL .IntegrationTests // Octokit integration tests
143+ └──Octokit .GraphQL .UnitTests // Octokit unit tests
144+ ```
0 commit comments