Skip to content

Commit

Permalink
Accept Graphene wrapped GraphQL schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Dec 24, 2021
1 parent 1ccebee commit 476edf3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
8 changes: 5 additions & 3 deletions graphql_server/aiohttp/graphqlview.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ def __init__(self, **kwargs):
if hasattr(self, key):
setattr(self, key, value)

assert isinstance(
self.schema, GraphQLSchema
), "A Schema is required to be provided to GraphQLView."
if not isinstance(self.schema, GraphQLSchema):
# maybe the GraphQL schema is wrapped in a Graphene schema
self.schema = getattr(self.schema, "graphql_schema", None)
if not isinstance(self.schema, GraphQLSchema):
raise TypeError("A Schema is required to be provided to GraphQLView.")

def get_root_value(self):
return self.root_value
Expand Down
8 changes: 5 additions & 3 deletions graphql_server/flask/graphqlview.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ def __init__(self, **kwargs):
if hasattr(self, key):
setattr(self, key, value)

assert isinstance(
self.schema, GraphQLSchema
), "A Schema is required to be provided to GraphQLView."
if not isinstance(self.schema, GraphQLSchema):
# maybe the GraphQL schema is wrapped in a Graphene schema
self.schema = getattr(self.schema, "graphql_schema", None)
if not isinstance(self.schema, GraphQLSchema):
raise TypeError("A Schema is required to be provided to GraphQLView.")

def get_root_value(self):
return self.root_value
Expand Down
8 changes: 5 additions & 3 deletions graphql_server/quart/graphqlview.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ def __init__(self, **kwargs):
if hasattr(self, key):
setattr(self, key, value)

assert isinstance(
self.schema, GraphQLSchema
), "A Schema is required to be provided to GraphQLView."
if not isinstance(self.schema, GraphQLSchema):
# maybe the GraphQL schema is wrapped in a Graphene schema
self.schema = getattr(self.schema, "graphql_schema", None)
if not isinstance(self.schema, GraphQLSchema):
raise TypeError("A Schema is required to be provided to GraphQLView.")

def get_root_value(self):
return self.root_value
Expand Down
8 changes: 5 additions & 3 deletions graphql_server/sanic/graphqlview.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ def __init__(self, **kwargs):
if hasattr(self, key):
setattr(self, key, value)

assert isinstance(
self.schema, GraphQLSchema
), "A Schema is required to be provided to GraphQLView."
if not isinstance(self.schema, GraphQLSchema):
# maybe the GraphQL schema is wrapped in a Graphene schema
self.schema = getattr(self.schema, "graphql_schema", None)
if not isinstance(self.schema, GraphQLSchema):
raise TypeError("A Schema is required to be provided to GraphQLView.")

def get_root_value(self):
return self.root_value
Expand Down
8 changes: 5 additions & 3 deletions graphql_server/webob/graphqlview.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ def __init__(self, **kwargs):
if hasattr(self, key):
setattr(self, key, value)

assert isinstance(
self.schema, GraphQLSchema
), "A Schema is required to be provided to GraphQLView."
if not isinstance(self.schema, GraphQLSchema):
# maybe the GraphQL schema is wrapped in a Graphene schema
self.schema = getattr(self.schema, "graphql_schema", None)
if not isinstance(self.schema, GraphQLSchema):
raise TypeError("A Schema is required to be provided to GraphQLView.")

def get_root_value(self):
return self.root_value
Expand Down

0 comments on commit 476edf3

Please sign in to comment.