Skip to content

Instantly share code, notes, and snippets.

@chaudum
Created January 7, 2019 09:00
Show Gist options
  • Save chaudum/6e62806e28edfac837852fea2f732220 to your computer and use it in GitHub Desktop.
Save chaudum/6e62806e28edfac837852fea2f732220 to your computer and use it in GitHub Desktop.
import graphene
class Result(graphene.ObjectType):
text = graphene.String(default_value="OK")
code = graphene.Int()
class Queries(graphene.ObjectType):
result = graphene.Field(Result)
def resolve_result(root, info):
return Result(code=200)
def test_default_value():
query = """
query {
result {
text
code
}
}
"""
schema = graphene.Schema(query=Queries)
result = schema.execute(query)
assert result.data["result"] == {'code': 200, 'text': 'OK'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment