🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

GraphQL.Query.Builder

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

GraphQL.Query.Builder

A tool to build GraphQL query from a C# model.

2.2.1
NuGet
Version published
Maintainers
1
Created
Source

GraphQL Query Builder .NET

logo

A tool to build GraphQL query from a C# model.

Build Status Coverage Nuget Downloads

See complete documentation here

See sample here

Install

dotnet add package GraphQL.Query.Builder

Usage

// Create the query
IQuery<Human> query = new Query<Human>("humans") // 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
//   }
// }

Console.WriteLine("{" + query.Build() + "}");
// Output:
// {humans(id:"uE78f5hq"){FirstName LastName HomePlanet{Name}Friends FirstName LastName}}

Keywords

graphql

FAQs

Package last updated on 28 Oct 2024

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