Skip to content

Commit

Permalink
chore: update graphene-django and refactor
Browse files Browse the repository at this point in the history
disable introspection via validation rules property
  • Loading branch information
derrabauke committed Dec 27, 2023
1 parent 6bd1d5a commit 2879aa8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
4 changes: 4 additions & 0 deletions caluma/caluma_user/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.http.response import HttpResponse
from django.utils.encoding import force_bytes, smart_str
from django.utils.module_loading import import_string
from graphene.validation import DisableIntrospection
from graphene_django.views import GraphQLView, HttpError
from rest_framework.authentication import get_authorization_header

Expand All @@ -19,6 +20,9 @@ class HttpResponseUnauthorized(HttpResponse):


class AuthenticationGraphQLView(GraphQLView):
if settings.DISABLE_INTROSPECTION: # pragma: no cover
validation_rules = (DisableIntrospection,)

def get_bearer_token(self, request):
auth = get_authorization_header(request).split()
header_prefix = "Bearer"
Expand Down
11 changes: 0 additions & 11 deletions caluma/schema.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from functools import partial

import graphene
from django.conf import settings
from graphene.relay import Node
from graphene.validation import DisableIntrospection
from graphene_django.converter import convert_django_field, convert_field_to_string
from graphene_django.debug import DjangoDebug
from graphql import validate
from localized_fields.fields import LocalizedField

from .caluma_analytics import schema as analytics_schema
Expand Down Expand Up @@ -97,10 +93,3 @@ class Query(*query_inherit_from):
# TODO: define what app exposes what types
types=types,
)

if settings.DISABLE_INTROSPECTION:
validate = partial(validate, rules=(DisableIntrospection,))

validation_errors = validate(
schema=schema.graphql_schema,
)
17 changes: 9 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ django-postgres-extra = "^2.0.4"
django-watchman = "^1.2.0"
djangorestframework = "^3.13.1"
django-simple-history = "^3.0.0"
graphene-django = "3.0.0b7"
graphene-django = "3.2.0"
graphql-relay = "^3.1.5"
idna = "^3.3"
minio = "^7.1.4"
Expand Down

0 comments on commit 2879aa8

Please sign in to comment.