Hypothesis strategies for GraphQL schemas, queries and data.
NOTE This package is experimental, some features are not supported yet.
Usage
There are a few strategies for different use cases.
Schema generation - hypothesis_graphql.strategies.schemas()
Query - hypothesis_graphql.strategies.queries(schema).
Mutation - hypothesis_graphql.strategies.mutations(schema).
Lets take this schema as an example:
type Book {
title: String
author: Author
}
type Author {
name: String
books: [Book]
}
type Query {
getBooks: [Book]
getAuthors: [Author]
}
type Mutation {
addBook(title: String!, author: String!): Book!
addAuthor(name: String!): Author!
}
Then strategies might be used in this way:
from hypothesis import given
from hypothesis_graphql import strategies as gql_st
SCHEMA = "..." # the one above
@given(query=gql_st.queries(SCHEMA))
def test_query(query):
...
# This query might be generated:
#
# query {
# getBooks {
# title
# }
# }
@given(mutation=gql_st.mutations(SCHEMA))
def test_mutation(mutation):
...
# This mutation might be generated:
#
# mutation {
# addBook(title: "H4Z\u7869", author: "\u00d2"){
# title
# }
# }
To restrict the set of fields in generated operations use the fields argument:
...
@given(query=gql_st.queries(SCHEMA, fields=["getAuthors"]))
def test_query(query):
# Only `getAuthors` will be generated
...
Metadata
Release files for hypothesis-graphql 0.6.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 |
|---|---|---|---|---|
| hypothesis-graphql-0.6.0.tar.gz | 11.7 kB | Without provenance | Details for hypothesis-graphql-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hypothesis_graphql-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for hypothesis_graphql-0.6.0-py3-none-any.whl |
Total release size: 25.7 kB
Release files / hypothesis-graphql-0.6.0.tar.gz
| Download URL | hypothesis-graphql-0.6.0.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0faba624362bc173a3b7f77fc70fbcddb182e7a1f33c8a115950eb906a71ea62
|
|
BLAKE2b-256 checksum How to use checksums |
68267e8ddf44b3defd2150c6728a267e64543831668ce6a59428c8fe33dc831d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.12
|
Release files / hypothesis_graphql-0.6.0-py3-none-any.whl
| Download URL | hypothesis_graphql-0.6.0-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9922512472351e3485fa2ce1b1697df99b8813ac7e33ddbfa03e1b839bde3017
|
|
BLAKE2b-256 checksum How to use checksums |
24130afb9e273dbbcf8c83d1801a6fe6830d57232d33676ef2d964e7e0fae04a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.12
|
Security for hypothesis-graphql 0.6.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.