From e9f837b3c80534fa36c50ab9ab5edf3320bf7ccd Mon Sep 17 00:00:00 2001 From: Falk Date: Fri, 22 Dec 2023 17:51:02 +0100 Subject: [PATCH] chore: update graphene-django and refactor disable introspection via validation rules property --- caluma/caluma_user/views.py | 4 ++++ caluma/schema.py | 11 ----------- poetry.lock | 17 +++++++++-------- pyproject.toml | 2 +- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/caluma/caluma_user/views.py b/caluma/caluma_user/views.py index 87d91cea5..3417cd04b 100644 --- a/caluma/caluma_user/views.py +++ b/caluma/caluma_user/views.py @@ -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 @@ -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" diff --git a/caluma/schema.py b/caluma/schema.py index d2377e5a7..0fb6becd2 100644 --- a/caluma/schema.py +++ b/caluma/schema.py @@ -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 @@ -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, -) diff --git a/poetry.lock b/poetry.lock index c57af9c47..64952d95a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -933,26 +933,27 @@ test = ["coveralls (>=3.3,<4)", "iso8601 (>=1,<2)", "mock (>=4,<5)", "pytest (>= [[package]] name = "graphene-django" -version = "3.0.0b7" +version = "3.2.0" description = "Graphene Django integration" optional = false python-versions = "*" files = [ - {file = "graphene-django-3.0.0b7.tar.gz", hash = "sha256:b1a4ce1a2227b1e77f67f0bc2fadd59c1d05016cb9aced45ab65f8612fba2c87"}, - {file = "graphene_django-3.0.0b7-py2.py3-none-any.whl", hash = "sha256:0f226ec7db744a54dbc5d6db2aa52d945701ae800e1055046dec2b76a539550a"}, + {file = "graphene-django-3.2.0.tar.gz", hash = "sha256:9aca4a862f12912c2e611624bdbcf6b0f9bc7a41d240110a41bf95575a7bacab"}, + {file = "graphene_django-3.2.0-py2.py3-none-any.whl", hash = "sha256:b553ecdc1cd7fd5b2d71de1a729c03ae117321763a90ed48a7fb4fdbf7f0d43f"}, ] [package.dependencies] -Django = ">=2.2" -graphene = ">=3.0.0b5,<4" +Django = ">=3.2" +graphene = ">=3.0,<4" graphql-core = ">=3.1.0,<4" +graphql-relay = ">=3.1.1,<4" promise = ">=2.1" text-unidecode = "*" [package.extras] -dev = ["black (==19.10b0)", "coveralls", "django-filter (>=2)", "djangorestframework (>=3.6.3)", "flake8 (==3.7.9)", "flake8-black (==0.1.1)", "flake8-bugbear (==20.1.4)", "mock", "pytest (>=3.6.3)", "pytest-cov", "pytest-django (>=3.3.2)", "pytest-random-order", "pytz"] +dev = ["coveralls", "django-filter (>=22.1)", "djangorestframework (>=3.6.3)", "mock", "pre-commit", "pytest (>=7.3.1)", "pytest-cov", "pytest-django (>=4.5.2)", "pytest-random-order", "pytz", "ruff (==0.1.2)"] rest-framework = ["djangorestframework (>=3.6.3)"] -test = ["coveralls", "django-filter (>=2)", "djangorestframework (>=3.6.3)", "mock", "pytest (>=3.6.3)", "pytest-cov", "pytest-django (>=3.3.2)", "pytest-random-order", "pytz"] +test = ["coveralls", "django-filter (>=22.1)", "djangorestframework (>=3.6.3)", "mock", "pytest (>=7.3.1)", "pytest-cov", "pytest-django (>=4.5.2)", "pytest-random-order", "pytz"] [[package]] name = "graphql-core" @@ -2438,4 +2439,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = "^3.8.1" -content-hash = "9f3c9155b69454d60e711bcb83292b2bb2267fffebb16aec111b7717073d8e14" +content-hash = "b4b8575ec1881250db8e6a775e2eb1084ea262cfc54a54ddcb2ed07dc14f3eb6" diff --git a/pyproject.toml b/pyproject.toml index 8c0f5e923..93d2d223e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"