Contents, indices and tables¶
Quick start¶
Installation¶
pip install slothql
Defining schema¶
import slothql
class Query(slothql.Object):
hello = slothql.String(resolver=lambda: 'world')
schema = slothql.Schema(query=Query)
slothql.gql(schema=schema, query='query { hello }')
# output: {'data': {'hello', 'world'}}
Fields¶
slothql.Field¶
Base class for all fields
many: bool = False one or many objects
class Query(slothql.Object): field = slothql.String(resolver=lambda: 'hello, world') fields = slothql.String(many=True, resolver=lambda: ['hello', 'world'])
default: Any = None value to return, when field resolves to None