NGql.Core 1.0.0

.NET 6.0
NuGet\Install-Package NGql.Core -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package NGql.Core --version 1.0.0
<PackageReference Include="NGql.Core" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NGql.Core --version 1.0.0
#r "nuget: NGql.Core, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install NGql.Core as a Cake Addin
#addin nuget:?package=NGql.Core&version=1.0.0

// Install NGql.Core as a Cake Tool
#tool nuget:?package=NGql.Core&version=1.0.0

Project Logo

NGql

Schemaless GraphQL client for .NET Core.

GitHub license

Quick Start

dotnet add package NGql.Core

Usage

Core library allows creation of Query and Mutation's. Both have an implicit conversion to string.

Query

var query = new Query("PersonAndFilms")
    .Select(new Query("person")
        .Where("id", "cGVvcGxlOjE=")
        .Select("name")
        .Select(new Query("filmConnection")
            .Select(new Query("films")
                .Select("title")))
    );

the output will be the following

query PersonAndFilms{
    person(id:"cGVvcGxlOjE="){
        name
        filmConnection{
            films{
                title
            }
        }
    }
}

Mutation

var mutation = new Mutation("CreateUser")
                .Select(new Query("createUser")
                    .Where("name", "Name")
                    .Where("password", "Password")
                    .Select("id", "name"))
                .ToString();

the output will be the following

mutation CreateUser{
    createUser(name:"Name", password:"Password"){
        id
        name
    }
}

Variables

Variables allows to reuse existing queries and mutations instead of building them from start every time.

Passing variables

var variable = new Variable("$name", "String");

// pass as constructor parameter
var ctor = new Query("name", variables: variable);

// or as method variable
var fluent = new Query("name", variables: variable).Variable(variable););

the output will be the following

query name($name:String){
    id
}

Getting data from server

You can check QueryTests that uses GraphQL.Client

var graphQLClient = new GraphQLHttpClient("http://swapi.apis.guru/", new NewtonsoftJsonSerializer());

var query = new Query("PersonAndFilms")
    .Select(new Query("person")
        .Where("id", "cGVvcGxlOjE=")
        .Select("name")
        .Select(new Query("filmConnection")
            .Select(new Query("films")
                .Select("title")))
    );

var request = new GraphQLRequest
{
    Query = query
};
var graphQLResponse = await graphQLClient.SendQueryAsync<ResponseType>(request);

var personName = graphQLResponse.Data.Person.Name;
Product Versions
.NET net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on NGql.Core:

Package Downloads
NGql.Client

Schemaless GraphQL client for .NET Core

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 1,820 11/28/2021
0.1.6 771 11/19/2021
0.1.5 967 10/22/2021
0.1.3 835 10/11/2021
0.1.2 335 9/15/2021
0.1.1 235 9/9/2021
0.1.0 197 9/9/2021