• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

octokit/octokit.graphql.net: A GitHub GraphQL client library for .NET

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

octokit/octokit.graphql.net

开源软件地址(OpenSource Url):

https://github.com/octokit/octokit.graphql.net

开源编程语言(OpenSource Language):

C# 99.9%

开源软件介绍(OpenSource Introduction):

Octokit.GraphQL

Build status codecov NuGet

Note: This software is currently beta. There are few things left, and there might be bugs - be warned!

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.

Documentation

You can find our documentation here.

Installing from Nuget

Install-Package Octokit.GraphQL -IncludePrerelease

Usage Example

using Octokit.GraphQL;
using static Octokit.GraphQL.Variable;
   
var productInformation = new ProductHeaderValue("YOUR_PRODUCT_NAME", "YOUR_PRODUCT_VERSION");
var connection = new Connection(productInformation, YOUR_OAUTH_TOKEN);

var query = new Query()
    .RepositoryOwner(Var("owner"))
    .Repository(Var("name"))
    .Select(repo => new
    {
        repo.Id,
        repo.Name,
        repo.Owner.Login,
        repo.IsFork,
        repo.IsPrivate,
    }).Compile();

var vars = new Dictionary<string, object>
{
    { "owner", "octokit" },
    { "name", "octokit.graphql.net" },
};

var result =  await connection.Run(query, vars);

Console.WriteLine(result.Login + " & " + result.Name + " Rocks!");
using Octokit.GraphQL;
using Octokit.GraphQL.Model;
using System;
using System.Linq;
using System.Threading.Tasks;

namespace Octokit
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var productInformation = new ProductHeaderValue("ExampleCode", "1.0");

            // Personal Access Token - needs a scope of 'read:user'
            var connection = new Connection(productInformation, "LOGGED_IN_GITHUB_USER_TOKEN");

            // A query to list out who you are actively sponsoring
            // That auto pages through all sponsors
            var query = new Query()
                .Viewer
                .SponsorshipsAsSponsor()
                .AllPages()
                .Select(sponsoring => new
                {
                    User = sponsoring.Sponsorable
                            .Cast<User>()
                            .Select(x => new { 
                                x.Login,
                                x.Name,
                                x.Id
                            })
                            .Single()
                })
                .Compile();

            var result = await connection.Run(query);

            // Sponsoring 'warrenbuckley' ?
            var activeSponsor = result.SingleOrDefault(x => x.User.Login.ToLowerInvariant() == "warrenbuckley");
            if(activeSponsor != null)
            {
                Console.WriteLine("Thanks for sponsoring Warren");
            }
        }
    }
}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap