Skip to content

Commit

Permalink
Merge pull request #15 from graphql-python/middleware-executor-improv…
Browse files Browse the repository at this point in the history
…ement

Simplified schema logic for the GraphQLView
  • Loading branch information
syrusakbary committed Nov 8, 2016
2 parents 66a10ad + 3847069 commit 89727b8
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions flask_graphql/graphqlview.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ def __init__(self, **kwargs):
if hasattr(self, key):
setattr(self, key, value)

inner_schema = getattr(self.schema, 'schema', None)
if not self.executor:
self.executor = getattr(self.schema, 'executor', None)

if inner_schema:
self.schema = inner_schema

assert isinstance(self.schema, GraphQLSchema), 'A Schema is required to be provided to GraphQLView.'

# noinspection PyUnusedLocal
Expand All @@ -56,6 +49,12 @@ def get_root_value(self, request):
def get_context(self, request):
return request

def get_middleware(self, request):
return self.middleware

def get_executor(self, request):
return self.executor

def dispatch_request(self):
try:
if request.method.lower() not in ('get', 'post'):
Expand Down Expand Up @@ -181,8 +180,8 @@ def execute_graphql_request(self, data, query, variables, operation_name, show_g
variable_values=variables or {},
operation_name=operation_name,
context_value=self.get_context(request),
middleware=self.middleware,
executor=self.executor
middleware=self.get_middleware(request),
executor=self.get_executor(request)
)
except Exception as e:
return ExecutionResult(errors=[e], invalid=True)
Expand Down

0 comments on commit 89727b8

Please sign in to comment.