charlesdevandiere/graphql-query-builder-dotnet

GraphQL Query Builder

See complete documentation here

GraphQL Query Builder

.NET

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

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}}
Issues

Quick list of the latest Issues we found

dahari87

dahari87

Icon For Comments0

Hi, i have the following method: public string GetQuery(params Expression<Func<MyClass, object>>[] properties){} so i able to use it this way: GetQuery(x => x.FirstName, x => x.NestedProp.NestedValue);

how can i map the properties array to a valid IQuery? tried the following:

can someone please give me a hint? thanks in advanced

DaveRMaltby

DaveRMaltby

Icon For Comments1

For a project that I'm working on, at runtime, I'm generating GraphQL queries that are displayed to the user. Therefore, I wanted the output of your library to contain appropriate line breaks and indentations. I've accomplished this on my own fork, but wondered if there is any interest in me providing a PR here to add this optional formatting to the output. Thanks.

malbaladejo

malbaladejo

Icon For Comments1

Thanks for this project. I've been looking for such builder for a while. I've write a GraphQL query builder and the syntax is similar to yours. I will follow your project with attention.

Versions

Quick list of the latest released versions

2.0.1 - Sep 05, 2022

Fix:

  • The Formatter from Query was not passed to the QueryStringBuilder. #35 Thanks @VictoriaKalinichenko!

2.0.0 - Apr 21, 2022

Breaking Changes

Deletions

  • Dawn.Guard dependency.

1.6.0 - Apr 04, 2022

Added

String arguments are now encoded:

1.5.0 - Apr 01, 2022

Added

Query<TSource>.AddArguments<TArguments>(TArguments arguments) method now supports inner object:

Thanks @carloshenriquecarniatto!

1.4.0 - Mar 31, 2022

Added

  • DateTime support for query param #27

1.3.0 - Mar 15, 2022

Added

QueryStringBuilder.FormatQueryParam is now virtual. You can override it to change query param formatting (see: CustomQueryStringBuilderTests.cs). Thanks to @sokolowskip #24

1.2.1 - Jan 05, 2021

Removed class restriction to allow working with records

Co-authored-by: @MigueZS

1.2.0 - Dec 10, 2020

Changes

  • Upgrade sample and tests to .NET 5
  • Upgrade Newtonsoft.Json to 12.0.3 #8

1.1.3 - Dec 10, 2020

Fixed

  • Is now possible to call AddField when base type is interface.

1.1.1 - May 13, 2020

Changes

Support new query param types

New query param types supported:

  • byte
  • sbyte
  • short
  • ushort
  • uint
  • long
  • ulong
  • decimal

1.0.1 - May 13, 2020

Changes

Upgrade Dawn.Guard to 1.12.0

1.0.0 - Mar 12, 2020

Outsourcing from GraphQL.Client.Extensions

Outsourcing GraphQL query building from GraphQL.Client.Extensions v2.1.0.

Library Stats (Sep 19, 2022)

Subscribers: 5
Stars: 34
Forks: 13
Issues: 5

dotnet-sshdeploy

here, otherwise you are in the right place

dotnet-sshdeploy

SharpeningCobaltStrike

In realtime compiling of dotnet v35/v40 exe/dll binaries + obfuscation with ConfuserEx on your linux cobalt strike server

SharpeningCobaltStrike

Dotnet client for Tarantool NoSql database

Some methods are not implemented yet because there are no direct analogs in IProto

Dotnet client for Tarantool NoSql database

dotnet-coverageconverter

coverage (binary format) files to

dotnet-coverageconverter

dotnet-stellar-sdk Stellar API SDK for

Report Bug · Report Security Vulnerability

dotnet-stellar-sdk Stellar API SDK for

dotnet-jwk is a JSON Web Key manager for dotnet

It allow to generate, encrypt, decrypt, convert and check JWK

dotnet-jwk is a JSON Web Key manager for dotnet

dotnet add package Brighid

Protecting the Client Secret

dotnet add package Brighid

dotnet-real-time-chat

A real time chat using C# dotnet and RabbitMQ

dotnet-real-time-chat

Run command line tools inside CSharp

Example running some dotnet CLI commands:

Run command line tools inside CSharp

Run command line tools inside CSharp

Example running some dotnet CLI commands:

Run command line tools inside CSharp
dotnet tool install --global dotnet-extract