Example #1
0
 def test_execute_saved_query_with_variable(self):
     resp = execute_saved_query("gql-2",
                                user=self.user,
                                variables={
                                    "name": "site-1"
                                }).to_dict()
     self.assertFalse(resp["data"].get("error"))
Example #2
0
 def run(self, request, pk):
     try:
         query = get_object_or_404(self.queryset, pk=pk)
         result = execute_saved_query(query.slug, variables=request.data.get("variables"), request=request).to_dict()
         return Response(result)
     except GraphQLError as error:
         return Response(
             {"errors": [GraphQLView.format_error(error)]},
             status=status.HTTP_400_BAD_REQUEST,
         )
Example #3
0
 def run(self, request, pk):
     try:
         result = execute_saved_query(pk,
                                      variables=request.data,
                                      request=request).to_dict()
         return Response(result)
     except GraphQLError as error:
         return Response(
             {"errors": [GraphQLView.format_error(error)]},
             status=status.HTTP_400_BAD_REQUEST,
         )
Example #4
0
 def test_execute_saved_query(self):
     resp = execute_saved_query("gql-1", user=self.user).to_dict()
     self.assertFalse(resp["data"].get("error"))