mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-02-16 19:40:36 +03:00
Fixed middleware
This commit is contained in:
parent
70dbd4b512
commit
8caa2cd00f
|
@ -1,11 +1,13 @@
|
|||
import cookbook.ingredients.schema
|
||||
import graphene
|
||||
|
||||
from graphene_django.debug import DjangoDebug
|
||||
|
||||
# print cookbook.ingredients.schema.Query._meta.graphql_type.get_fields()['allIngredients'].args
|
||||
|
||||
|
||||
class Query(cookbook.ingredients.schema.Query, graphene.ObjectType):
|
||||
pass
|
||||
debug = graphene.Field(DjangoDebug, name='__debug')
|
||||
|
||||
|
||||
schema = graphene.Schema(query=Query)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import inspect
|
||||
import json
|
||||
import re
|
||||
|
||||
|
@ -42,6 +43,14 @@ def get_accepted_content_types(request):
|
|||
key=lambda x: x[1], reverse=True))
|
||||
|
||||
|
||||
def instantiate_middleware(middlewares):
|
||||
for middleware in middlewares:
|
||||
if inspect.isclass(middleware):
|
||||
yield middleware()
|
||||
continue
|
||||
yield middleware
|
||||
|
||||
|
||||
class GraphQLView(View):
|
||||
graphiql_version = '0.7.8'
|
||||
graphiql_template = 'graphene/graphiql.html'
|
||||
|
@ -60,7 +69,8 @@ class GraphQLView(View):
|
|||
middleware = graphene_settings.MIDDLEWARE
|
||||
|
||||
self.schema = schema
|
||||
self.middleware = MiddlewareManager(middleware)
|
||||
if middleware is not None:
|
||||
self.middleware = MiddlewareManager(*list(instantiate_middleware(middleware)))
|
||||
self.executor = executor
|
||||
self.root_value = root_value
|
||||
self.pretty = pretty
|
||||
|
|
Loading…
Reference in New Issue
Block a user