Socket
Book a DemoInstallSign in
Socket

GraphQL.Client.Extensions

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

GraphQL.Client.Extensions

Extensions for GraphQL.Client to build graphQL queries from a C# model.

nugetNuGet
Version
4.0.0
Version published
Maintainers
1
Created
Source

GraphQL Client Extensions

logo

Extensions for GraphQL.Client to build graphQL queries from a C# model.

Build Status Azure DevOps coverage (branch) Nuget Downloads

Uses GraphQL.Query.Builder for query building.

See complete documentation here

See sample here

Install

dotnet add package GraphQL.Client.Extensions

Usage

// create the query with GraphQL.Query.Builder
Query<Human> query = new Query<Human>("humans", options) // set the name of the query
    .AddArguments(new { id = "uE78f5hq" }) // add query arguments
    .AddField(h => h.FirstName) // add firstName field
    .AddField(h => h.LastName) // add lastName field
    .AddField( // add a sub-object field
        h => h.HomePlanet, // set the name of the field
        sq => sq /// build the sub-query
            .AddField(p => p.Name)
    )
    .AddField<human>( // add a sub-list field
        h => h.Friends,
        sq => sq
            .AddField(f => f.FirstName)
            .AddField(f => f.LastName)
    );
// this corresponds to :
// humans (id: "uE78f5hq") {
//   FirstName
//   LastName
//   HomePlanet {
//     Name
//   }
//   Friends {
//     FirstName
//     LastName
//   }
// }

using (GraphQLClient client = new("<url>"))
{
    // run the query
    Human human = await client.Get<Human>(query);
}

Dependencies

Keywords

graphql

FAQs

Package last updated on 26 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts