Created
January 7, 2019 09:00
-
-
Save chaudum/6e62806e28edfac837852fea2f732220 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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