omnixys-graphql
Shared GraphQL toolkit for Omnixys Python services: strawberry/FastAPI wiring, a transport-independent error contract, typed error factories, sanitization, and pagination primitives.
Installation
pip install omnixys-graphql
Features
- Error catalog — the full
@omnixys/contracts-tsErrorCodeenum andERROR_DEFINITIONS(summary, default message, HTTP status, retryability, public metadata keys) ported to Python. - Typed errors —
BaseGraphQLExceptionand domain exceptions (UserNotFoundException,EventNotFoundException, …) that render stableextensions(code, summary, httpStatus, retryable, timestamp, metadata). - Factory helpers —
validation_graphql_error,unauthenticated_graphql_error,forbidden_graphql_error,not_found_graphql_error,conflict_graphql_error,rate_limit_graphql_error,dependency_unavailable_graphql_error,internal_graphql_error,access_blocked,step_up_required. - Error formatting —
create_graphql_format_errorstandardizes every response error, collapses internal details to safe defaults, and strips sensitive metadata; unknown codes map to a service-level internal code. - Pagination —
PageInput/PagePayloadstrawberry types. - Router wiring —
create_graphql_router/include_graphql_routerwith a Dishka-aware context getter.
Note: the package imports as
omnixys_graphql. It deliberately does not shadow thegraphqlmodule name, which belongs tographql-core(required by strawberry).
Quick start
import strawberry
from fastapi import FastAPI
from omnixys_graphql import create_graphql_router, include_graphql_router
@strawberry.type
class Query:
@strawberry.field
def ping(self) -> str:
return "pong"
schema = strawberry.Schema(query=Query)
app = FastAPI()
include_graphql_router(app, schema, graphiql=True)
Error handling
Raise a typed error from a resolver and it renders with stable extensions:
from omnixys_graphql import EventNotFoundException, UserNotFoundException
@strawberry.type
class Query:
@strawberry.field
def event(self, event_id: str) -> str:
raise EventNotFoundException(event_id)
Response extensions:
{
"code": "EVENT_NOT_FOUND",
"summary": "Event not found.",
"httpStatus": 404,
"retryable": false,
"timestamp": "2026-01-01T00:00:00Z",
"metadata": { "eventId": "evt_123" }
}
Only metadata keys listed for the code survive; sanitize_details also drops
anything sensitive (password, token, authorization, …), truncates nesting
beyond depth 5, and caps arrays at 50 entries.
Factories
from omnixys_graphql import (
access_blocked,
forbidden_graphql_error,
rate_limit_graphql_error,
step_up_required,
validation_graphql_error,
)
raise validation_graphql_error("bad input", {"field": "email"})
raise forbidden_graphql_error("no permission")
raise rate_limit_graphql_error()
raise access_blocked(["2fa_pending"])
raise step_up_required("mfa", ["low_risk_score"])
Standardizing responses
Attach GraphQLFormatErrorExtension to your schema to normalize every error to
the catalog contract:
from strawberry import Schema
from omnixys_graphql import GraphQLFormatErrorOptions, GraphQLFormatErrorExtension
schema = Schema(
query=Query,
extensions=[
lambda: GraphQLFormatErrorExtension(
GraphQLFormatErrorOptions(service_name="event-service"),
),
],
)
The extension keeps client-safe messages (httpStatus < 500) as-is and replaces
internal messages with the catalog default, so stack traces never leak. Unknown
codes normalize to the service internal code (e.g. EVENT_INTERNAL_ERROR).
Use the lambda factory so a fresh extension is built per request.
Error catalog
from omnixys_graphql import (
ERROR_CATALOG_VERSION,
ErrorCode,
get_error_definition,
get_public_error_metadata,
is_known_error_code,
)
definition = get_error_definition(ErrorCode.RATE_LIMIT_EXCEEDED.value)
assert definition.http_status == 429
assert definition.retryable is True
metadata = get_public_error_metadata("EVENT_NOT_FOUND", {"eventId": "e1", "secret": 1})
assert metadata == {"eventId": "e1"}
Pagination
from omnixys_graphql import PageInput, PagePayload
payload = PagePayload(items=[1, 2, 3], total=10, page=1, size=3)
assert payload.has_next() is True
Development
uv sync
uv run pytest -q
uv run ruff check .
uv run mypy src/
License
GPL-3.0-or-later
Metadata
Release files for omnixys-graphql 4.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| omnixys_graphql-4.0.0.tar.gz | 55.1 kB | Without provenance | Details for omnixys_graphql-4.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| omnixys_graphql-4.0.0-py3-none-any.whl | Python 3 | none | any | Details for omnixys_graphql-4.0.0-py3-none-any.whl |
Total release size: 72.9 kB
Release files / omnixys_graphql-4.0.0.tar.gz
| Download URL | omnixys_graphql-4.0.0.tar.gz |
|---|---|
| Size | 55.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
495eed7c519ee2924f5da9db3527fbfbdf069a389b59781ec88eed98d2ea3dd4
|
|
BLAKE2b-256 checksum How to use checksums |
2c41c24bc10d34249e6d49e232c734e6b03dcfb46908f221ab7ccfb30f1ebabd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / omnixys_graphql-4.0.0-py3-none-any.whl
| Download URL | omnixys_graphql-4.0.0-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
08653d1c329288364e6fbb57e0f5936fe8549ab4c0d8383f6d8e48ea541f4e7b
|
|
BLAKE2b-256 checksum How to use checksums |
7c1ab5a7e635443e8f4e9cc31d2d026e4699b1509d96536d5777df7cd460028e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for omnixys-graphql 4.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.