From 7b6f2b6c8a093766d6e3276ab7537b3dd231acf9 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 19 Apr 2022 15:22:22 +0200 Subject: [PATCH 1/3] python3Packages.graphene: fix graphql-core==3.2.0 compat --- .../python-modules/graphene/default.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkgs/development/python-modules/graphene/default.nix b/pkgs/development/python-modules/graphene/default.nix index e975bff8fee4..7d44f4c6a245 100644 --- a/pkgs/development/python-modules/graphene/default.nix +++ b/pkgs/development/python-modules/graphene/default.nix @@ -1,6 +1,7 @@ { lib , aniso8601 , buildPythonPackage +, fetchpatch , fetchFromGitHub , graphql-core , graphql-relay @@ -29,6 +30,20 @@ buildPythonPackage rec { sha256 = "0qgp3nl6afyz6y27bw175hyqppx75pp1vqwl7nvlpwvgwyyc2mnl"; }; + patches = [ + # Fix graphql-core 3.2.0 support + (fetchpatch { + # https://github.com/graphql-python/graphene/pull/1378 + url = "https://github.com/graphql-python/graphene/commit/989970f89341ebb949962d13dcabca8a6ccddad4.patch"; + hash = "sha256-qRxWTqv5XQN7uFjL2uv9NjTvSLi76/MyFSa4jpkb8to="; + }) + (fetchpatch { + # https://github.com/graphql-python/graphene/pull/1417 + url = "https://github.com/graphql-python/graphene/commit/4e0e18d1682b7759bdf16499c573f675c7fb51cb.patch"; + hash = "sha256-icdTGDabJouQ3hVpcMkkeabNwdoDxdVVAboTOWFbO94="; + }) + ]; + propagatedBuildInputs = [ aniso8601 graphql-core @@ -53,6 +68,8 @@ buildPythonPackage rec { # Expects different Exeception classes, but receives none of them # https://github.com/graphql-python/graphene/issues/1346 "test_unexpected_error" + # https://github.com/graphql-python/graphene/pull/1417#issuecomment-1102492138 + "test_example_end_to_end" ] ++ lib.optionals (pythonAtLeast "3.10") [ "test_objecttype_as_container_extra_args" "test_objecttype_as_container_invalid_kwargs" From 021fad3832c5b234be31c31e5f69394745e0a2d3 Mon Sep 17 00:00:00 2001 From: Ember 'n0emis' Keske Date: Tue, 19 Apr 2022 16:36:19 +0200 Subject: [PATCH 2/3] python3Packages.graphene-django: unstable-2021-06-11 -> unstable-2022-03-03 --- .../graphene-django/default.nix | 10 +- .../graphene-django/graphene-3_2_0.patch | 150 ++++++++++++++++++ 2 files changed, 157 insertions(+), 3 deletions(-) create mode 100644 pkgs/development/python-modules/graphene-django/graphene-3_2_0.patch diff --git a/pkgs/development/python-modules/graphene-django/default.nix b/pkgs/development/python-modules/graphene-django/default.nix index f736fbe39d85..404a6779505b 100644 --- a/pkgs/development/python-modules/graphene-django/default.nix +++ b/pkgs/development/python-modules/graphene-django/default.nix @@ -19,17 +19,21 @@ buildPythonPackage rec { pname = "graphene-django"; - version = "unstable-2021-06-11"; + version = "unstable-2022-03-03"; format = "setuptools"; disabled = pythonOlder "3.6"; src = fetchFromGitHub { owner = "graphql-python"; repo = pname; - rev = "e7f7d8da07ba1020f9916153f17e97b0ec037712"; - sha256 = "0b33q1im90ahp3gzy9wx5amfzy6q57ydjpy5rn988gh81hbyqaxv"; + rev = "f6ec0689c18929344c79ae363d2e3d5628fa4a2d"; + hash = "sha256-KTZ5jcoeHYXnlaF47t8jIi6+7NyMyA4hDPv+il3bt+U="; }; + patches = [ + ./graphene-3_2_0.patch + ]; + postPatch = '' substituteInPlace setup.py \ --replace '"pytest-runner"' "" diff --git a/pkgs/development/python-modules/graphene-django/graphene-3_2_0.patch b/pkgs/development/python-modules/graphene-django/graphene-3_2_0.patch new file mode 100644 index 000000000000..0e8fa63464a3 --- /dev/null +++ b/pkgs/development/python-modules/graphene-django/graphene-3_2_0.patch @@ -0,0 +1,150 @@ +diff --git a/graphene_django/filter/tests/test_fields.py b/graphene_django/filter/tests/test_fields.py +index 7d440f4..0aec6e4 100644 +--- a/graphene_django/filter/tests/test_fields.py ++++ b/graphene_django/filter/tests/test_fields.py +@@ -1005,7 +1005,7 @@ def test_integer_field_filter_type(): + + schema = Schema(query=Query) + +- assert str(schema) == dedent( ++ assert str(schema).rstrip() + "\n" == dedent( + """\ + type Query { + pets(offset: Int = null, before: String = null, after: String = null, first: Int = null, last: Int = null, age: Int = null): PetTypeConnection +@@ -1074,7 +1074,7 @@ def test_other_filter_types(): + + schema = Schema(query=Query) + +- assert str(schema) == dedent( ++ assert str(schema).rstrip() + "\n" == dedent( + """\ + type Query { + pets(offset: Int = null, before: String = null, after: String = null, first: Int = null, last: Int = null, age: Int = null, age_Isnull: Boolean = null, age_Lt: Int = null): PetTypeConnection +diff --git a/graphene_django/tests/test_command.py b/graphene_django/tests/test_command.py +index 70116b8..a4ab4db 100644 +--- a/graphene_django/tests/test_command.py ++++ b/graphene_django/tests/test_command.py +@@ -49,7 +49,7 @@ def test_generate_graphql_file_on_call_graphql_schema(): + assert handle.write.called_once() + + schema_output = handle.write.call_args[0][0] +- assert schema_output == dedent( ++ assert schema_output.rstrip() + "\n" == dedent( + """\ + type Query { + hi: String +diff --git a/graphene_django/tests/test_types.py b/graphene_django/tests/test_types.py +index bde72c7..0b64440 100644 +--- a/graphene_django/tests/test_types.py ++++ b/graphene_django/tests/test_types.py +@@ -247,7 +247,7 @@ def test_schema_representation(): + } + """ + ) +- assert str(schema) == expected ++ assert str(schema).rstrip() + "\n" == expected + + + def with_local_registry(func): +@@ -515,7 +515,7 @@ class TestDjangoObjectType: + + schema = Schema(query=Query) + +- assert str(schema) == dedent( ++ assert str(schema).rstrip() + "\n" == dedent( + """\ + type Query { + pet: Pet +@@ -541,7 +541,7 @@ class TestDjangoObjectType: + + schema = Schema(query=Query) + +- assert str(schema) == dedent( ++ assert str(schema).rstrip() + "\n" == dedent( + """\ + type Query { + pet: Pet +@@ -576,7 +576,7 @@ class TestDjangoObjectType: + + schema = Schema(query=Query) + +- assert str(schema) == dedent( ++ assert str(schema).rstrip() + "\n" == dedent( + """\ + type Query { + pet: Pet +@@ -603,7 +603,7 @@ class TestDjangoObjectType: + + schema = Schema(query=Query) + +- assert str(schema) == dedent( ++ assert str(schema).rstrip() + "\n" == dedent( + """\ + type Query { + pet: PetModelKind +@@ -642,7 +642,7 @@ class TestDjangoObjectType: + + schema = Schema(query=Query) + +- assert str(schema) == dedent( ++ assert str(schema).rstrip() + "\n" == dedent( + """\ + type Query { + pet: PetModelKind +diff --git a/graphene_django/tests/test_views.py b/graphene_django/tests/test_views.py +index 945fa87..e2e8b46 100644 +--- a/graphene_django/tests/test_views.py ++++ b/graphene_django/tests/test_views.py +@@ -109,12 +109,10 @@ def test_reports_validation_errors(client): + { + "message": "Cannot query field 'unknownOne' on type 'QueryRoot'.", + "locations": [{"line": 1, "column": 9}], +- "path": None, + }, + { + "message": "Cannot query field 'unknownTwo' on type 'QueryRoot'.", + "locations": [{"line": 1, "column": 21}], +- "path": None, + }, + ] + } +@@ -135,8 +133,6 @@ def test_errors_when_missing_operation_name(client): + "errors": [ + { + "message": "Must provide operation name if query contains multiple operations.", +- "locations": None, +- "path": None, + } + ] + } +@@ -476,8 +472,7 @@ def test_handles_syntax_errors_caught_by_graphql(client): + "errors": [ + { + "locations": [{"column": 1, "line": 1}], +- "message": "Syntax Error: Unexpected Name 'syntaxerror'.", +- "path": None, ++ "message": "Syntax Error: Unexpected Name 'syntaxerror'." + } + ] + } +diff --git a/graphene_django/views.py b/graphene_django/views.py +index c23b020..f533f70 100644 +--- a/graphene_django/views.py ++++ b/graphene_django/views.py +@@ -11,7 +11,6 @@ from django.views.decorators.csrf import ensure_csrf_cookie + from django.views.generic import View + from graphql import OperationType, get_operation_ast, parse, validate + from graphql.error import GraphQLError +-from graphql.error import format_error as format_graphql_error + from graphql.execution import ExecutionResult + + from graphene import Schema +@@ -387,7 +386,7 @@ class GraphQLView(View): + @staticmethod + def format_error(error): + if isinstance(error, GraphQLError): +- return format_graphql_error(error) ++ return error.formatted + + return {"message": str(error)} + From 896c716d1b8fa7b39ed1c96f4ae9ec3f3e957a37 Mon Sep 17 00:00:00 2001 From: Ember 'n0emis' Keske Date: Tue, 19 Apr 2022 16:37:18 +0200 Subject: [PATCH 3/3] netbox: 3.1.10 -> 3.2.1 --- nixos/tests/web-apps/netbox.nix | 2 +- pkgs/servers/web-apps/netbox/default.nix | 33 +++++++++++-------- .../web-apps/netbox/graphql-3_2_0.patch | 21 ++++++++++++ 3 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 pkgs/servers/web-apps/netbox/graphql-3_2_0.patch diff --git a/nixos/tests/web-apps/netbox.nix b/nixos/tests/web-apps/netbox.nix index 95f24029ec92..35decdd49e87 100644 --- a/nixos/tests/web-apps/netbox.nix +++ b/nixos/tests/web-apps/netbox.nix @@ -5,7 +5,7 @@ import ../make-test-python.nix ({ lib, pkgs, ... }: { maintainers = [ n0emis ]; }; - machine = { ... }: { + nodes.machine = { ... }: { services.netbox = { enable = true; secretKeyFile = pkgs.writeText "secret" '' diff --git a/pkgs/servers/web-apps/netbox/default.nix b/pkgs/servers/web-apps/netbox/default.nix index a8abcf9d8573..988076947bc2 100644 --- a/pkgs/servers/web-apps/netbox/default.nix +++ b/pkgs/servers/web-apps/netbox/default.nix @@ -10,15 +10,6 @@ let py = python3.override { packageOverrides = self: super: { django = super.django_3; - graphql-core = super.graphql-core.overridePythonAttrs (old: rec { - version = "3.1.7"; - src = fetchFromGitHub { - owner = "graphql-python"; - repo = old.pname; - rev = "v${version}"; - sha256 = "1mwwh55qd5bcpvgy6pyliwn8jkmj4yk4d2pqb6mdkgqhdic2081l"; - }; - }); jsonschema = super.jsonschema.overridePythonAttrs (old: rec { version = "3.2.0"; src = self.fetchPypi { @@ -28,14 +19,26 @@ let }; }); lxml = super.lxml.overridePythonAttrs (old: rec { - pname = "lxml"; version = "4.6.5"; - src = self.fetchPypi { - inherit pname version; + pname = old.pname; + inherit version; sha256 = "6e84edecc3a82f90d44ddee2ee2a2630d4994b8471816e226d2b771cda7ac4ca"; }; }); + werkzeug = super.werkzeug.overridePythonAttrs (old: rec { + version = "2.0.3"; + src = self.fetchPypi { + pname = "Werkzeug"; + inherit version; + sha256 = "sha256-uGP4/wV8UiFktgZ8niiwQRYbS+W6TQ2s7qpQoWOCLTw="; + }; + }); + sentry-sdk = super.sentry-sdk.overridePythonAttrs (old: rec { + disabledTestPaths = old.disabledTestPaths ++ [ + "tests/integrations/flask/test_flask.py" + ]; + }); }; }; @@ -43,13 +46,13 @@ let in py.pkgs.buildPythonApplication rec { pname = "netbox"; - version = "3.1.10"; + version = "3.2.1"; src = fetchFromGitHub { owner = "netbox-community"; repo = pname; rev = "v${version}"; - sha256 = "sha256-qREq4FJHHTA9Vm6f9kSfiYqur2omFmdsoZ4OdaPFcpU="; + sha256 = "sha256-iA0KIgaHQh0OsN/tXmTATIlvnf0aLRdjeQ6VkiR9VJ4="; }; format = "other"; @@ -57,6 +60,7 @@ py.pkgs.buildPythonApplication rec { patches = [ # Allow setting the STATIC_ROOT from within the configuration and setting a custom redis URL ./config.patch + ./graphql-3_2_0.patch ]; propagatedBuildInputs = with py.pkgs; [ @@ -75,6 +79,7 @@ py.pkgs.buildPythonApplication rec { django-timezone-field djangorestframework drf-yasg + swagger-spec-validator # from drf-yasg[validation] graphene-django jinja2 markdown diff --git a/pkgs/servers/web-apps/netbox/graphql-3_2_0.patch b/pkgs/servers/web-apps/netbox/graphql-3_2_0.patch new file mode 100644 index 000000000000..1e97b7d85ce0 --- /dev/null +++ b/pkgs/servers/web-apps/netbox/graphql-3_2_0.patch @@ -0,0 +1,21 @@ +diff --git a/netbox/netbox/graphql/scalars.py b/netbox/netbox/graphql/scalars.py +index 7d14189dd..0a18e79d2 100644 +--- a/netbox/netbox/graphql/scalars.py ++++ b/netbox/netbox/graphql/scalars.py +@@ -1,6 +1,6 @@ + from graphene import Scalar + from graphql.language import ast +-from graphql.type.scalars import MAX_INT, MIN_INT ++from graphql.type.scalars import GRAPHQL_MAX_INT, GRAPHQL_MIN_INT + + + class BigInt(Scalar): +@@ -10,7 +10,7 @@ class BigInt(Scalar): + @staticmethod + def to_float(value): + num = int(value) +- if num > MAX_INT or num < MIN_INT: ++ if num > GRAPHQL_MAX_INT or num < GRAPHQL_MIN_INT: + return float(num) + return num +