mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 04:07:16 +03:00
Merge pull request #11 from mbetz08/master
Django 1.6 compatibility for views
This commit is contained in:
commit
625c6da282
|
@ -1,6 +1,6 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from django.http import JsonResponse
|
from django.http import HttpResponse
|
||||||
from django.views.generic import View
|
from django.views.generic import View
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
@ -25,11 +25,10 @@ class GraphQLView(View):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def response_errors(self, *errors):
|
def response_errors(self, *errors):
|
||||||
return JsonResponse({
|
errors = [{
|
||||||
"errors": [{
|
|
||||||
"message": str(e)
|
"message": str(e)
|
||||||
} for e in errors]
|
} for e in errors]
|
||||||
})
|
return HttpResponse(json.dumps({'errors': errors}), content_type='application/json')
|
||||||
|
|
||||||
def execute_query(self, request, query):
|
def execute_query(self, request, query):
|
||||||
if not query:
|
if not query:
|
||||||
|
@ -42,7 +41,7 @@ class GraphQLView(View):
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
raise e
|
raise e
|
||||||
return self.response_errors(e)
|
return self.response_errors(e)
|
||||||
return JsonResponse(data)
|
return HttpResponse(json.dumps(data), content_type='application/json')
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
query = request.GET.get('query')
|
query = request.GET.get('query')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user