Skip to content

Commit dd702a1

Browse files
authored
Update readme.md
Signed-off-by: 0x5BFA <[email protected]>
1 parent d5573c3 commit dd702a1

File tree

1 file changed

+48
-54
lines changed

1 file changed

+48
-54
lines changed

readme.md

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
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 .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.
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 with GitHub GraphQL API
1218

13-
You can find our documentation [here](docs/readme.md).
19+
To learn more about GitHub GraphQL API, visit [GitHub Docs](https://docs.github.com/graphql/overview)
1420

15-
## Installing from Nuget
21+
## Usage
1622

23+
1. Install the NuGet package
1724
```
1825
Install-Package Octokit.GraphQL -IncludePrerelease
1926
```
20-
21-
## Usage Example
22-
23-
```csharp
27+
2. Feed the package
28+
```C#
2429
using Octokit.GraphQL;
2530
using static Octokit.GraphQL.Variable;
2631

27-
var productInformation = new ProductHeaderValue("YOUR_PRODUCT_NAME", "YOUR_PRODUCT_VERSION");
28-
var connection = new Connection(productInformation, YOUR_OAUTH_TOKEN);
32+
// Authenticate with a PAT with a scope 'read:user'
33+
var connection = new Connection(new("Octokit.GraphQL.Net.SampleApp", "1.0"), "LOGGED_IN_GITHUB_USER_TOKEN");
2934

3035
var query = new Query()
3136
.RepositoryOwner(Var("owner"))
@@ -50,52 +55,41 @@ var result = await connection.Run(query, vars);
5055
Console.WriteLine(result.Login + " & " + result.Name + " Rocks!");
5156
```
5257

53-
```csharp
58+
```C#
5459
using Octokit.GraphQL;
5560
using Octokit.GraphQL.Model;
5661
using System;
5762
using System.Linq;
5863
using System.Threading.Tasks;
5964

60-
namespace Octokit
61-
{
62-
class Program
65+
// Authenticate with a PAT with a scope 'read:user'
66+
var connection = new Connection(new("Octokit.GraphQL.Net.SampleApp", "1.0"), "LOGGED_IN_GITHUB_USER_TOKEN");
67+
68+
// A query to list out who you are actively sponsoring
69+
// That auto pages through all sponsors
70+
var query = new Query()
71+
.Viewer
72+
.SponsorshipsAsSponsor()
73+
.AllPages()
74+
.Select(sponsoring => new
6375
{
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)
76+
User = sponsoring.Sponsorable
77+
.Cast<User>()
78+
.Select(x => new
9579
{
96-
Console.WriteLine("Thanks for sponsoring Warren");
97-
}
98-
}
99-
}
80+
x.Login,
81+
x.Name,
82+
x.Id
83+
}.Single()
84+
}).Compile();
85+
86+
// Queries from the GraphQL API end point
87+
var result = await connection.Run(query);
88+
89+
// Check if sponsoring 'warrenbuckley'
90+
var activeSponsor = result.SingleOrDefault(x => x.User.Login.ToLowerInvariant() == "warrenbuckley");
91+
if(activeSponsor != null)
92+
{
93+
Console.WriteLine("Thanks for sponsoring Warren");
10094
}
10195
```

0 commit comments

Comments
 (0)