Skip to content

Commit 20bfbca

Browse files
committed
wip files
1 parent 5c093cd commit 20bfbca

File tree

1 file changed

+20
-0
lines changed
  • baseapp-core/baseapp_core/graphql

1 file changed

+20
-0
lines changed

baseapp-core/baseapp_core/graphql/views.py

+20
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import json, logging
2+
13
from django.http.response import HttpResponseBadRequest
24
from graphene_django.views import GraphQLView as GrapheneGraphQLView
35
from graphene_django.views import HttpError
46
from graphql import get_operation_ast, parse
57
from graphql.execution import ExecutionResult
8+
from graphene_file_upload.utils import place_files_in_operations
69

710
try:
811
import sentry_sdk
@@ -37,3 +40,20 @@ def execute_graphql_request(
3740
return super().execute_graphql_request(
3841
request, data, query, variables, operation_name, show_graphiql
3942
)
43+
44+
45+
def parse_body(self, request):
46+
"""Handle multipart request spec for multipart/form-data"""
47+
content_type = self.get_content_type(request)
48+
# logging.info('content_type: %s' % content_type)
49+
# import pdb; pdb.set_trace()
50+
if content_type == 'multipart/form-data' and 'operations' in request.POST:
51+
operations = json.loads(request.POST.get('operations', '{}'))
52+
# import pdb; pdb.set_trace()
53+
files_map = json.loads(request.POST.get('map', '{}'))
54+
return place_files_in_operations(
55+
operations,
56+
files_map,
57+
request.FILES
58+
)
59+
return super(GraphQLView, self).parse_body(request)

0 commit comments

Comments
 (0)