Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

metaengine-graphql-go-nethttp

Generate idiomatic Go net/http clients and models from GraphQL schemas. Self-contained — no .NET runtime required.

Part of MetaEngine.

Install

go install

go install github.com/meta-engine/metaengine-graphql-go-nethttp@latest

Homebrew

brew install meta-engine/tap/metaengine-graphql-go-nethttp

Shell (macOS / Linux)

curl -fsSL https://raw.githubusercontent.com/meta-engine/metaengine-graphql-go-nethttp/main/install.sh | sh

Or download a prebuilt binary for your platform from the Releases page.

Usage

metaengine-graphql-go-nethttp <input> <output> <module> <package> [flags]
Argument Description
input GraphQL schema file path (SDL)
output Output directory for the generated code
module Go module name (e.g. github.com/acme/api)
package Go package name (e.g. client)

Example

metaengine-graphql-go-nethttp schema.graphql ./client github.com/acme/api client \
  --documentation --error-handling --retries 3

Flags

Flag Description
--documentation Generate Go doc comments (carries GraphQL schema descriptions through)
--options-threshold <n> Use an options struct for operations with more than n arguments
--validate-struct-tags Add validate struct tags to generated models
--timeout <seconds> Set the HTTP client timeout
--base-url-env <name> Read the base URL from this environment variable at runtime
--bearer-auth <env> Add bearer-token auth; the token is read from this environment variable
--bearer-header <name> Use a custom header name for the bearer token (with --bearer-auth)
--basic-auth <userEnv:passEnv> Add basic auth; username/password read from these environment variables
--retries [n] Retry failed requests, optionally capping at n attempts
--header <name:env> Add a custom request header sourced from an environment variable (repeatable)
--middleware Generate a request/response middleware hook on the client
--error-handling Map HTTP error status codes to Go errors (>= 400 → typed *HTTPStatusError)
--throw-for <codes> Return a formatted error (HTTP <code>: <body>) for these status codes (comma-separated)
--return-null-for <codes> Return the ErrNullResponse sentinel for these status codes
--return-error-for <codes> Return a typed *HTTPStatusError for these status codes
--fragments Generate reusable fragment types
--oneof-inputs Honor @oneOf on input types (exactly-one-field inputs)
--clean Remove stale files from the output directory before writing
--verbose Verbose logging

Generated clients take a context.Context and use pointers for optional fields by default. The WebSocket URL for GraphQL subscriptions is a constructor parameter on the generated client, set at runtime — there is no generation-time flag for it.

License

MIT

About

MetaEngine GraphQL -> Go (net/http) generator — self-contained, no .NET required

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages