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:
        #         print('graphapi/views: get_response bailed ')
        #         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)

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)

Revert "Reimplement using explicit variable lookup"
Revert "Reimplement using explicit variable lookup"

This reverts commit 94683e6c

  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:
+         if not show_graphiql:
-         #     error = verify_request(request, 'graphapi')
+             error = verify_request(request, 'graphapi')
-         #     if error:
+             if error:
-         #         print('graphapi/views: get_response bailed ')
-         #         return error, error.status_code
+                 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)
  
Revert "Reimplement using explicit variable lookup"
## Code Before:
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:
        #         print('graphapi/views: get_response bailed ')
        #         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)

## Instruction:
Revert "Reimplement using explicit variable lookup"
## Code After:
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)
