from simplekeys.verifier import verify_request
from graphene_django.views import GraphQLView
from django.conf import settings


class KeyedGraphQLView(GraphQLView):
    graphiql_template = "graphene/graphiql-keyed.html"

    def get_response(self, request, data, show_graphiql=False):
        # check key only if we're not handling a graphiql request
        if not show_graphiql:
            error = verify_request(request, 'graphapi')
            if error:
                return error, error.status_code

        return super().get_response(request, data, show_graphiql)

    def render_graphiql(self, request, **data):
        data['demo_key'] = settings.GRAPHQL_DEMO_KEY
        return super().render_graphiql(request, **data)

@@ -119,16 +119,32 @@
 ettings%0A
+import newrelic%0A
 %0A%0Aclass 
@@ -390,16 +390,309 @@
 aphiql:%0A
+            newrelic.agent.add_custom_parameter(%0A                'key',%0A                request.META.get(getattr(settings, 'SIMPLEKEYS_HEADER', 'HTTP_X_API_KEY'))%0A            )%0A            newrelic.agent.add_custom_parameter(%0A                'request-data',%0A                data%0A            )%0A
         

add some newrelic tracing