Search code examples
djangodjango-rest-frameworkrequestgraphqlresponse

How to get query strings through GraphQL and trigger a function to return a response with Django?


We are trying to get check-boxed items list from front-end as a request query to a GraphQL endpoint and with that request trigger one function to manipulate the selected items in Django to return a response.

This is for a web application to process files when get query from front-end to a GraphQL endpoint. And upload it to a s3 bucket and return a link to file as response. Using DRF we could achieve it with request.POST and getting the items with a object filter. With GraphQL how to achieve it? Do we need to use mutation or just a query is enough to trigger a function at back-end.

Receive the query request with selected items list, trigger a function to manipulate the items got through query and return a response. How can we implement this with GraphQL and Django?


Solution

  • We figured it out, get the check boxed items list as an argument in GraphQL as graphene.List(graphene.Int) and process that argument in mutate function, return response.