Update custom GraphQLView to use new GraphQL 3.0 syntax
This commit is contained in:
parent
6f563806f7
commit
a2e85c337d
|
|
@ -1,4 +1,5 @@
|
|||
from django.http.request import HttpRequest
|
||||
from graphql import get_operation_ast, parse
|
||||
import requests
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
|
|
@ -22,11 +23,13 @@ class SentryGraphQLView(GraphQLView):
|
|||
operation_name,
|
||||
show_graphiql,
|
||||
):
|
||||
operation_type = (
|
||||
self.get_backend(request)
|
||||
.document_from_string(self.schema, query)
|
||||
.get_operation_type(operation_name)
|
||||
)
|
||||
"""
|
||||
adapted to use the new GraphQL 3.0 syntax, still need to get the operation type,
|
||||
but the code to do this changed significantly, so the above link only explains
|
||||
the 'what' and 'why', but no longer the 'how'
|
||||
"""
|
||||
document = parse(query)
|
||||
operation_type = get_operation_ast(document, operation_name).operation
|
||||
with start_transaction(op=operation_type, name=operation_name):
|
||||
return super().execute_graphql_request(
|
||||
request, data, query, variables, operation_name, show_graphiql
|
||||
|
|
|
|||
Loading…
Reference in New Issue