Skip to content

Instantly share code, notes, and snippets.

@tudormunteanu
Last active November 26, 2021 17:40
Show Gist options
  • Save tudormunteanu/62bfc542b79314a8ee0d957c589b8d47 to your computer and use it in GitHub Desktop.
Save tudormunteanu/62bfc542b79314a8ee0d957c589b8d47 to your computer and use it in GitHub Desktop.
(graphene_mypy)  ~/work/zego/experiments/graphene_mypy/ cat app/api/schema.py
from graphene import Boolean, Field, ObjectType, ResolveInfo
class Query(ObjectType):
healthy = Boolean() <--------------- this is what the Graphene docs deem as recommended
@staticmethod
def resolve_healthy(_: None, __: ResolveInfo) -> bool:
return True
(graphene_mypy)  ~/work/zego/experiments/graphene_mypy/ mypy .
app/api/schema.py:8: error: No field with name "healthy" defined <------------- graphene-stubs can't find the field.
Found 1 error in 1 file (checked 3 source files)
(graphene_mypy)  ~/work/zego/experiments/graphene_mypy/ cat app/api/schema.py
from graphene import Boolean, Field, ObjectType, ResolveInfo
class Query(ObjectType):
healthy = Field(Boolean) <------------ only this syntax makes graphene-stubs happy
@staticmethod
def resolve_healthy(_: None, __: ResolveInfo) -> bool:
return True
(graphene_mypy)  ~/work/zego/experiments/graphene_mypy/ mypy .
Success: no issues found in 3 source files <------------------ no errors. wat?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment