metaengine-graphql-go-nethttp
GraphQL SDL → an idiomatic Go net/http client and structs with typed queries, mutations & subscriptions (subscriptions surface as (<-chan T, <-chan error) over a graphql-transport-ws WebSocket via github.com/coder/websocket), plus bearer/basic auth, retries, timeouts, error handling, fragments, and @oneOf inputs. context.Context-first methods and *T pointers for optional fields by default. Delivered as a self-contained single binary — no .NET runtime required.
Pick your registry
The same generator, published to every ecosystem we support. Install however your project expects.
Drive it from the CLI or programmatically
GitHub Releases ships a zero-config CLI. NuGet ships the same generator as a C# fluent API — same options, same output.
After install, point the CLI at your schema. It writes the generated tree to your chosen output directory.
metaengine-graphql-go-nethttp <input> <output> <module> <package> [flags]Generates an idiomatic Go net/http client and structs from a GraphQL SDL schema — typed queries, mutations & subscriptions. Queries and mutations travel over HTTP POST; subscriptions resolve to (<-chan T, <-chan error) over a graphql-transport-ws WebSocket (github.com/coder/websocket), with the WebSocket URL passed to the client constructor at runtime. <input> is a GraphQL schema file path (SDL); <module> is the Go module name (e.g. github.com/acme/api) and <package> the Go package name (e.g. client). Methods take a context.Context and use *T pointers for optional fields by default. Ships as a self-contained single binary — no .NET runtime required.
metaengine-graphql-go-nethttp schema.graphql ./client github.com/acme/api client --documentation --error-handling --retries 3metaengine-graphql-go-nethttp schema.graphql ./client github.com/acme/api client --bearer-auth API_TOKEN --timeout 30 --header X-Tenant-ID:TENANT_IDmetaengine-graphql-go-nethttp schema.graphql ./client github.com/acme/api client --fragments --oneof-inputs --validate-struct-tagsEvery knob, documented
Every option is available on the C# fluent API as a method, and most are also exposed as CLI flags. Cross-cutting auth, headers, retries and timeouts apply across frameworks.
Go Options
6WithDocumentation()Generate Go doc comments on methods and types, carrying GraphQL SDL descriptions throughWithValidateStructTags()Emit validate:"required" struct tags on non-null fields of generated modelsWithContext()context.Context as the first method parameter (engine default; the CLI exposes no opt-out)WithPointersForOmittable()Use *T pointers for optional fields so omitted vs. zero is distinguishable (engine default)WithMethodNames(Func)Custom method naming rule with access to operation contextWithOptionsObjectThreshold(int)Parameter count at which a method switches to an options struct (default: 4)
Auth · Headers · Resilience
15WithErrorHandling()Smart error handling based on HTTP status (404 / 403 → ErrNullResponse sentinel · 400 / 422 → error body · 401 / 5xx → typed *HTTPStatusError). GraphQL queries/mutations travel over HTTP POST.WithErrorHandling(errors => errors...)Per-status routing via handleResponse: ReturnNullFor(404, 403) · ReturnErrorFor(400, 422) · ThrowFor(401, 500)WithBearerAuth()Bearer token from env var (default API_TOKEN) — adds an Authorization headerWithBearerAuth(string)Bearer token from a specific env var nameWithBearerAuth(string, string)Bearer token from an env var with a custom header name (e.g. X-Api-Key)WithBasicAuth()HTTP Basic auth from default env vars (API_USERNAME / API_PASSWORD)WithBasicAuth(string, string)HTTP Basic auth from username + password env varsWithCustomHeader(string, string)Static header sourced from an env var. Repeatable (e.g. X-Tenant-ID ← TENANT_ID)WithBaseUrlEnvVar(string)Read the base URL from an env var at runtime (default API_BASE_URL)WithTimeout(double)Request timeout in seconds for all operationsWithTimeout(double?, double?, double?, double?)Granular timeout: connect · read · write · pool (seconds)WithRetries()Retries with exponential backoff over retryable status codes (default 429, 503)WithRetries(int)Retries with a custom max-attempts countWithRetries(int, double, double, int[])Retries with full custom settings: max attempts · base delay · max delay · retryable status codesWithMiddleware()Generate RoundTripper middleware infrastructure (a request/response hook on the client)
GraphQL Options
5WithFragments()Emit reusable named fragments for object-type selections (...TypeFields spreads, hoisted into fragments.go)WithOneOfInputs()Generate idiomatic @oneOf input types (tagged-union inputs where exactly one field is set)WithCustomScalar(string, Type)Map a GraphQL custom scalar to a System.Type for Go resolution (e.g. DateTime → time.Time). Unmapped scalars default to stringWithTypeFilter(Func)Filter extracted GraphQL types before registration — only types returning true are generatedWithDocumentation()Carry SDL type/field descriptions through as Go doc comments
Naming Transformations
3Types(Func)Transform type namesPaths(Func)Transform output pathsFileNames(Func)Transform file names
File Management
5CleanDestination()Clean output directory before generationAlwaysOverwrite()Always overwrite existing filesOnlyWhenModelChanged()Update only when model changesOnlyWhenNew()Write only new files, preserve existingCleanDirectories(...)Clean specific subdirectories
Diagnostics
2Verbose()Enable verbose loggingWithLogger(Action<string>)Route generation log output to a custom sink