metaengine-graphql-httpx
GraphQL SDL → an async Python httpx client and Pydantic v2 models with typed queries, mutations & subscriptions (subscriptions surface as an AsyncIterator over a graphql-transport-ws WebSocket), plus bearer/basic auth, retries, timeouts, error handling, fragments, and @oneOf inputs. Delivered as a pip-installable CLI — no .NET 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
PyPI 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-httpx <input> <output> [options]Generates an async Python httpx client and Pydantic v2 models from a GraphQL SDL schema — typed queries, mutations & subscriptions (subscriptions resolve to an AsyncIterator over a graphql-transport-ws WebSocket). <input> accepts a local SDL file path or inline SDL content. The wheel bundles a platform-native runner, so no .NET install is required.
metaengine-graphql-httpx ./schema.graphql ./generated --fragments --documentation --retries 3metaengine-graphql-httpx ./schema.graphql ./generated --bearer-auth API_TOKEN --timeout 30 --error-handlingmetaengine-graphql-httpx ./schema.graphql ./generated --sync-methods --custom-scalar DateTime=datetime --camel-case-aliasesEvery 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.
Python Options
6WithDocumentation()Generate docstring comments on methods and parameters from SDL descriptionsWithSyncMethods()Generate synchronous service methods alongside the async httpx clientWithCamelCaseAliases()Emit camelCase aliases on Pydantic models (populate_by_name — accepts snake_case and camelCase JSON)WithMiddleware()Generate httpx transport middleware infrastructure (Middleware type + chain helpers)WithMethodNames(Func)Custom method naming ruleWithOptionsObjectThreshold(int)Parameter count at which a method switches to an options object (default: 4)
Auth · Headers · Resilience
14WithErrorHandling()Smart error handling based on HTTP status (404 / 403 → None · 400 / 422 → error body · 401 / 5xx → raise). GraphQL operations travel over HTTP POST.WithErrorHandling(errors => errors...)Per-status routing: ReturnNullFor(404, 403) · ReturnErrorFor(400, 422) · ThrowFor(401, 500)WithBearerAuth()Bearer token from env var (default API_TOKEN) — adds Authorization headerWithBearerAuth(string)Bearer token from a specific env var nameWithBearerAuth(string, string)Bearer token 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 from an env var. Repeatable (e.g. X-Tenant-ID ← TENANT_ID)WithBaseUrlEnvVar(string)Read the base URL from an env var (default API_BASE_URL)WithTimeout(double)Request timeout in seconds for all operationsWithTimeout(double?, double?, ...)Granular httpx timeout: connect · read · write · poolWithRetries()Retries with exponential backoff (default status 429, 503)WithRetries(int)Retries with a custom max-attempts countWithRetries(int, double, double, int[])Retries with full custom settings including retryable status codes
GraphQL Options
5WithFragments()Emit reusable named fragments for object-type selections (...TypeFields spreads)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 Python type (e.g. DateTime → datetime). Unmapped scalars default to strWithSubscriptionUrl(string)Path appended to baseUrl for the GraphQL WebSocket subscription endpoint (default: /graphql). The client upgrades http→ws / https→wss; subscriptions surface as an AsyncIterator over the graphql-transport-ws subprotocolWithTypeFilter(Func)Filter extracted GraphQL types before registration — only types returning true are generated
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
1EnableVerboseLogging()Enable detailed logging