hypothesis-graphql
Hypothesis strategies for GraphQL queries
Decision gist · record as of 2026-08-14
Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and solves a real testing problem—finding edge cases in GraphQL backends through property-based testing. It integrates cleanly with Hypothesis and supports both positive and negative test generation. Recommended for any project with a GraphQL API that needs robust backend validation.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Low friction: pure Python wheel with only two runtime dependencies (graphql-core and hypothesis).
- Actively maintained with a release 31 days ago and no known vulnerabilities.
License · maintenance · safety
MIT (permissive) — MIT license (permissive) — you can use this freely in commercial and open-source projects with minimal restrictions.
last release 2026-07-14 (31 days) · last repo commit 2026-08-10 · 48 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,888,327 downloads/mo, #2,840 on PyPI
Alternatives
Verify before relying
from hypothesis import given
from hypothesis_graphql import from_schema
SCHEMA = "type Query { getBooks: [String] }"
@given(from_schema(SCHEMA))
def test_graphql(query):
# query is a generated GraphQL string
response = requests.post("http://localhost/graphql", json={"query": query})
assert response.status_code == 200- Whether the library supports all GraphQL spec features (subscriptions, directives, interfaces, unions) or has known limitations.
- Performance characteristics when generating queries against very large schemas.
- Whether custom scalar strategies can handle complex nested types beyond the documented examples.
What it is and what it does
hypothesis-graphql is a Hypothesis strategy library that generates valid (and optionally invalid) GraphQL queries matching your schema. It integrates with Hypothesis's property-based testing framework to create parametrized test cases with arbitrary query depth and field combinations, helping you find edge cases and error-handling gaps in your GraphQL backend that manual test cases might miss.
The library works by taking a GraphQL schema as input and returning a Hypothesis strategy that produces random but schema-compliant queries. You can customize generation via field restrictions, string encoding options, and custom scalar mappings. It also supports negative testing mode to generate intentionally invalid queries for validating your server's error handling.
Use it for
- Test a GraphQL API for crashes or unexpected behavior by generating thousands of random valid queries automatically.
- Validate error handling in your GraphQL server by generating invalid queries (wrong types, missing required args, null for non-null fields).
- Restrict query generation to specific fields to focus testing on a particular part of your schema.
- Generate custom scalar values (e.g., dates, UUIDs) that match your schema's domain constraints.
- Discover edge cases in nested query resolution that are unlikely to be covered by hand-written test cases.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is actively maintained, has no known vulnerabilities, low install friction, and solves a real testing problem—finding edge cases in GraphQL backends through property-based testing. It integrates cleanly with Hypothesis and supports both positive and negative test generation. Recommended for any project with a GraphQL API that needs robust backend validation.
Install
hypothesis-graphql on PyPI
Before you install
Low friction: pure Python wheel with only two runtime dependencies (graphql-core and hypothesis). Actively maintained with a release 31 days ago and no known vulnerabilities.
Requires Python 3.10 or later.
License in practice
MIT license (permissive) — you can use this freely in commercial and open-source projects with minimal restrictions.
Quickstart
from hypothesis import given
from hypothesis_graphql import from_schema
SCHEMA = "type Query { getBooks: [String] }"
@given(from_schema(SCHEMA))
def test_graphql(query):
# query is a generated GraphQL string
response = requests.post("http://localhost/graphql", json={"query": query})
assert response.status_code == 200
Verify before relying
- Whether the library supports all GraphQL spec features (subscriptions, directives, interfaces, unions) or has known limitations.
- Performance characteristics when generating queries against very large schemas.
- Whether custom scalar strategies can handle complex nested types beyond the documented examples.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesgraphql-corehypothesis |
| Maintenance | Actively maintained 31 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,888,327 / month, #2,840 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaEnvironment :: ConsoleFramework :: HypothesisIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: Testing |
Evidence: hypothesis_graphql-0.13.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “graphql query generation testing”
- hypothesis-graphqlGenerates arbitrary GraphQL queries matching your schema to use as…
- sgqlcsgqlc is a Python client library for querying GraphQL APIs using…
- Flask-GraphQLAdds a GraphQL endpoint to Flask applications, allowing you to serve…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also hypothesis-jsonschema · schemathesis · hypothesis · hegel-core · graphql-query · gql · python-graphql-client · ariadne-codegen · strawberry-graphql-django · enigma-api-client