ProtoTest.GraphQL
1.0.1
dotnet add package ProtoTest.GraphQL --version 1.0.1
NuGet\Install-Package ProtoTest.GraphQL -Version 1.0.1
<PackageReference Include="ProtoTest.GraphQL" Version="1.0.1" />
<PackageVersion Include="ProtoTest.GraphQL" Version="1.0.1" />
<PackageReference Include="ProtoTest.GraphQL" />
paket add ProtoTest.GraphQL --version 1.0.1
#r "nuget: ProtoTest.GraphQL, 1.0.1"
#:package ProtoTest.GraphQL@1.0.1
#addin nuget:?package=ProtoTest.GraphQL&version=1.0.1
#tool nuget:?package=ProtoTest.GraphQL&version=1.0.1
ProtoTest.GraphQL
Queries, mutations and subscriptions over named clients, with a fluent and a shape-driven builder, GraphQL-aware assertions and SDL-driven schema coverage.
dotnet add package ProtoTest.GraphQL
Quick start
builder.AddApplication("Api", app => app.AddGraphQL(graphQL => graphQL
.CaptureAttachments()
.AddClient("GraphQL")));
[Application("Api")]
public sealed class CatalogTests
{
[ProtoTest]
public async Task FindsProducts()
{
using var response = await Proto.Context.GraphQL()
.Query("products", new { first = 10 })
.ExpectAsync(new
{
nodes = new[]
{
new { id = JsonValue.NotNull(), name = JsonValue.StringContaining("note") }
},
pageInfo = new { hasNextPage = false }
});
response.ShouldHaveNoErrors();
}
}
What it adds
- Operations —
Proto.Context.GraphQL(name?)with fluentQuery/Mutation/Subscription(name, configure), shape-drivenQuery(rootField, arguments)+ExpectAsync(shape), andRequest(document)as the raw escape hatch. - Assertions —
ShouldHaveNoErrors(),ShouldHaveErrors(),ShouldHaveError(code),Should.HaveHttpStatus(...),ShouldMatchShape(...)andReadDataAs<T>(). - Subscriptions —
SubscribeAsync()overgraphql-transport-wsWebSocket or SSE, selected per target withWithSubscriptionTransport(...)orProtoTest:Applications:{app}:GraphQL:SubscriptionTransport; each event is a normalGraphQLResponse. - Uploads —
Gql.Upload(...)in shape arguments and variables builds the multipart request and preflight header automatically. - Coverage —
GraphQLCoverageCollectorcounts operations;WithSchemaCoverage()walks the SDL (inline, file or URL) and reports types, fields, arguments and input fields. - Tracing —
graphql.operationwith document and variables,graphql.responseobservations, redacted request/response attachments and subscription events.
Configuration
Under ProtoTest:GraphQL:Responses and ProtoTest:GraphQL:Attachments; the option types are shared with REST, each protocol owns a keyed instance.
| Key | Type | Default |
|---|---|---|
MaxResponseBodyBytes |
int |
10485760 (10 MiB) |
MaxDiagnosticBodyLength |
int |
65536 |
CaptureRequestBodies |
bool |
true |
CaptureResponses |
bool |
true |
CaptureExpectedShapes |
bool |
true |
RedactSensitiveData |
bool |
true |
SensitiveHeaders |
List<string> |
Authorization, Proxy-Authorization, Cookie, Set-Cookie, X-Api-Key |
SensitiveQueryParameters |
List<string> |
access_token, refresh_token, token, apiKey, api_key, key |
SensitiveJsonProperties |
List<string> |
password, token, access_token, refresh_token, secret, apiKey, api_key |
There is no batching, persisted operations or incremental @defer support; subscriptions speak only graphql-transport-ws, and a fluent .Argument("file", Gql.Upload(...)) is not routed through multipart normalization.
Learn more
| 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 is compatible. 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 is compatible. 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. |
-
net10.0
- HotChocolate.Language (>= 16.6.3)
- Microsoft.Extensions.Http (>= 10.0.12)
- ProtoTest.Core (>= 1.0.1)
- ProtoTest.Http (>= 1.0.1)
- ProtoTest.Json (>= 1.0.1)
-
net8.0
- HotChocolate.Language (>= 16.6.3)
- Microsoft.Extensions.Http (>= 8.0.1)
- ProtoTest.Core (>= 1.0.1)
- ProtoTest.Http (>= 1.0.1)
- ProtoTest.Json (>= 1.0.1)
-
net9.0
- HotChocolate.Language (>= 16.6.3)
- Microsoft.Extensions.Http (>= 9.0.20)
- ProtoTest.Core (>= 1.0.1)
- ProtoTest.Http (>= 1.0.1)
- ProtoTest.Json (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.