Apollo upload client support
See original GitHub issueHi!
I’m trying to use default example from apollo-upload-client. But it doesn’t work with graphene.
The problem is - the rquest headers contains content-type: multiform-data
, so parse_body
from views.py
returns request.POST
, BUT get_graphql_params
parse query only from GET request
And request contains query, but in POST…
So, my solution for apollo-upload-client is:
@staticmethod
def get_graphql_params(request, data):
query = request.GET.get('query') or data.get('query')
variables = request.GET.get('variables') or data.get('variables')
id = request.GET.get('id') or data.get('id')
# try to get params from POST
if not query:
if request.POST.get("operations"):
parsed_post = json.loads(request.POST.get("operations"))
if 'query' in parsed_post:
query = parsed_post['query']
if 'variables' in parsed_post:
variables = parsed_post['variables']
if variables and isinstance(variables, six.text_type):
try:
variables = json.loads(variables)
except Exception:
raise HttpError(HttpResponseBadRequest(
'Variables are invalid JSON.'))
operation_name = request.GET.get(
'operationName') or data.get('operationName')
if operation_name == "null":
operation_name = None
return query, variables, operation_name, id
After that, all appear to be ok:
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:5
Top Results From Across the Web
File uploads - Apollo GraphQL Docs
Apollo Client doesn't support a file upload feature out of the box. If you'd like to enable file upload capabilities, you will have...
Read more >jaydenseric/apollo-upload-client - GitHub
GitHub - jaydenseric/apollo-upload-client: A terminating Apollo Link for Apollo Client that fetches a GraphQL multipart request if the GraphQL variables ...
Read more >Top 5 apollo-upload-client Code Examples - Snyk
To help you get started, we've selected a few apollo-upload-client examples, based on popular ways it is used in public projects. Secure your...
Read more >apollo-upload-client examples - CodeSandbox
Learn how to use apollo-upload-client by viewing and forking example apps that make use of apollo-upload-client on CodeSandbox.
Read more >apollo-fetch-upload/readme.md - UNPKG
For server instructions see [`apollo-upload-server`](https://github.com/jaydenseric/apollo-upload-server). Checkout the [example API and client](https://github.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am also trying to get apollo-upload-client to play together with
graphene-django
. This issue seems related: https://stackoverflow.com/questions/48713911/apollo-upload-client-and-graphene-djangoA complete example would be awesome! 😃
@creimers, not a problem. https://gist.github.com/tvorogme/1c0794e1455bf3fc61162e2915ec2462