Hypothesis strategies for GraphQL schemas and queries
Project description
Hypothesis strategies for GraphQL schemas, queries and data.
NOTE This package is experimental, some features are not supported yet.
Usage
There are two strategies for different use cases.
Schema generation - hypothesis_graphql.strategies.schema()
Query - hypothesis_graphql.strategies.query(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]
}
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.query(SCHEMA))
def test_query(query):
...
# This query might be generated:
#
# query {
# getBooks {
# title
# }
# }
To restrict the set of fields in generated queries use the fields argument:
...
@given(query=gql_st.query(SCHEMA, fields=["getAuthors"]))
def test_query(query):
# Only `getAuthors` will be generated
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for hypothesis_graphql-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63e1ddf207cd86ebf957d9bb801c3761b2c2ac6dad67f31494e54549d786f97a |
|
MD5 | 10c4af7077dfc202eeee5d9ba668b032 |
|
BLAKE2b-256 | 6dc9ee57d62e5e7a1c7be6e4c6057cfc9ce848834a2ea8eb7aca9a5544fa8805 |