NpgsqlGraphQL 0.0.1-preview
dotnet add package NpgsqlGraphQL --version 0.0.1-preview
NuGet\Install-Package NpgsqlGraphQL -Version 0.0.1-preview
<PackageReference Include="NpgsqlGraphQL" Version="0.0.1-preview" />
<PackageVersion Include="NpgsqlGraphQL" Version="0.0.1-preview" />
<PackageReference Include="NpgsqlGraphQL" />
paket add NpgsqlGraphQL --version 0.0.1-preview
#r "nuget: NpgsqlGraphQL, 0.0.1-preview"
#:package NpgsqlGraphQL@0.0.1-preview
#addin nuget:?package=NpgsqlGraphQL&version=0.0.1-preview&prerelease
#tool nuget:?package=NpgsqlGraphQL&version=0.0.1-preview&prerelease
NpgsqlGraphQL
Tiny .NET client and GraphQL.NET transport adapter experiment for PostgreSQL's pg_graphql extension.
This package does not implement a GraphQL schema generator or EF Core provider.
PostgreSQL's pg_graphql extension owns schema reflection and execution. This library only calls
graphql.resolve(...) through Npgsql and plugs that execution into GraphQL.NET's ASP.NET Core transport.
Usage
await using var client = new NpgsqlGraphqlClient(connectionString);
await client.EnsureExtensionAsync();
var json = await client.ResolveAsync(
"""
query Blogs($first: Int!) {
blogCollection(first: $first) {
edges {
node {
id
title
}
}
}
}
""",
new { first = 10 });
ASP.NET Core
using Npgsql.GraphQL;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddNpgsqlGraphQL(
"Host=localhost;Port=5432;Database=postgres;Username=pgAdmin;Password=123456");
var app = builder.Build();
app.MapNpgsqlGraphQL("/graphql");
app.Run();
With PostgreSQL session settings for RLS or multi-tenancy:
builder.Services.AddNpgsqlGraphQL(options =>
{
options.ConnectionString = builder.Configuration.GetConnectionString("Postgres");
options.SetSessionSetting("app.source", "graphql");
options.MapClaimToSessionSetting("app.user_id", "sub");
});
app.MapNpgsqlGraphQL("/graphql", options =>
{
options.CsrfProtectionEnabled = false;
});
Request:
POST /graphql
Content-Type: application/json
{
"query": "query { blogCollection(first: 10) { edges { node { id title } } } }"
}
Frontend clients
The endpoint is a normal GraphQL HTTP endpoint, so frontend applications can use standard clients:
- React: Apollo Client, urql, Relay, or plain
fetch. - Vue: Vue Apollo or any framework-agnostic GraphQL client.
- TypeScript: GraphQL Code Generator can generate typed operations from schema/query documents.
The frontend still writes GraphQL operations, but they are usually colocated in .graphql files or gql tags
and can be type-generated instead of hand-parsed.
Notes
- Requires PostgreSQL with the
pg_graphqlextension installed. EnsureExtensionAsyncrunscreate extension if not exists pg_graphql;.- Query execution is delegated to
graphql.resolve. - The ASP.NET Core endpoint uses GraphQL.NET's HTTP transport and serializers.
NpgsqlGraphqlDocumentExecuterimplements GraphQL.NET'sIDocumentExecuter<ISchema>and delegates execution to PostgreSQL.- No .NET GraphQL schema is required; the
ExecutionOptions.Schemavalue is ignored because schema reflection lives in PostgreSQL. - PostgreSQL session settings are applied inside a transaction with
set_config(..., true). - PostgreSQL GraphQL error
extensions.codeis mapped to GraphQL.NET'sExecutionError.Code. - When GraphQL.NET enables execution metrics, the response includes an
extensions.npgsql.durationMsvalue.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- GraphQL.Server.Transports.AspNetCore (>= 8.3.3)
- GraphQL.SystemTextJson (>= 8.3.0)
- Npgsql (>= 10.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.1-preview | 70 | 5/29/2026 |