mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 07:23:20 +00:00
Merge pull request #169323 from n0emis/netbox-v3.2.1
This commit is contained in:
commit
0a0cf3d283
@ -5,7 +5,7 @@ import ../make-test-python.nix ({ lib, pkgs, ... }: {
|
|||||||
maintainers = [ n0emis ];
|
maintainers = [ n0emis ];
|
||||||
};
|
};
|
||||||
|
|
||||||
machine = { ... }: {
|
nodes.machine = { ... }: {
|
||||||
services.netbox = {
|
services.netbox = {
|
||||||
enable = true;
|
enable = true;
|
||||||
secretKeyFile = pkgs.writeText "secret" ''
|
secretKeyFile = pkgs.writeText "secret" ''
|
||||||
|
@ -19,17 +19,21 @@
|
|||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
pname = "graphene-django";
|
pname = "graphene-django";
|
||||||
version = "unstable-2021-06-11";
|
version = "unstable-2022-03-03";
|
||||||
format = "setuptools";
|
format = "setuptools";
|
||||||
disabled = pythonOlder "3.6";
|
disabled = pythonOlder "3.6";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "graphql-python";
|
owner = "graphql-python";
|
||||||
repo = pname;
|
repo = pname;
|
||||||
rev = "e7f7d8da07ba1020f9916153f17e97b0ec037712";
|
rev = "f6ec0689c18929344c79ae363d2e3d5628fa4a2d";
|
||||||
sha256 = "0b33q1im90ahp3gzy9wx5amfzy6q57ydjpy5rn988gh81hbyqaxv";
|
hash = "sha256-KTZ5jcoeHYXnlaF47t8jIi6+7NyMyA4hDPv+il3bt+U=";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
./graphene-3_2_0.patch
|
||||||
|
];
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
substituteInPlace setup.py \
|
substituteInPlace setup.py \
|
||||||
--replace '"pytest-runner"' ""
|
--replace '"pytest-runner"' ""
|
||||||
|
@ -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)}
|
||||||
|
|
@ -1,6 +1,7 @@
|
|||||||
{ lib
|
{ lib
|
||||||
, aniso8601
|
, aniso8601
|
||||||
, buildPythonPackage
|
, buildPythonPackage
|
||||||
|
, fetchpatch
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
, graphql-core
|
, graphql-core
|
||||||
, graphql-relay
|
, graphql-relay
|
||||||
@ -29,6 +30,20 @@ buildPythonPackage rec {
|
|||||||
sha256 = "0qgp3nl6afyz6y27bw175hyqppx75pp1vqwl7nvlpwvgwyyc2mnl";
|
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 = [
|
propagatedBuildInputs = [
|
||||||
aniso8601
|
aniso8601
|
||||||
graphql-core
|
graphql-core
|
||||||
@ -53,6 +68,8 @@ buildPythonPackage rec {
|
|||||||
# Expects different Exeception classes, but receives none of them
|
# Expects different Exeception classes, but receives none of them
|
||||||
# https://github.com/graphql-python/graphene/issues/1346
|
# https://github.com/graphql-python/graphene/issues/1346
|
||||||
"test_unexpected_error"
|
"test_unexpected_error"
|
||||||
|
# https://github.com/graphql-python/graphene/pull/1417#issuecomment-1102492138
|
||||||
|
"test_example_end_to_end"
|
||||||
] ++ lib.optionals (pythonAtLeast "3.10") [
|
] ++ lib.optionals (pythonAtLeast "3.10") [
|
||||||
"test_objecttype_as_container_extra_args"
|
"test_objecttype_as_container_extra_args"
|
||||||
"test_objecttype_as_container_invalid_kwargs"
|
"test_objecttype_as_container_invalid_kwargs"
|
||||||
|
@ -10,15 +10,6 @@ let
|
|||||||
py = python3.override {
|
py = python3.override {
|
||||||
packageOverrides = self: super: {
|
packageOverrides = self: super: {
|
||||||
django = super.django_3;
|
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 {
|
jsonschema = super.jsonschema.overridePythonAttrs (old: rec {
|
||||||
version = "3.2.0";
|
version = "3.2.0";
|
||||||
src = self.fetchPypi {
|
src = self.fetchPypi {
|
||||||
@ -28,14 +19,26 @@ let
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
lxml = super.lxml.overridePythonAttrs (old: rec {
|
lxml = super.lxml.overridePythonAttrs (old: rec {
|
||||||
pname = "lxml";
|
|
||||||
version = "4.6.5";
|
version = "4.6.5";
|
||||||
|
|
||||||
src = self.fetchPypi {
|
src = self.fetchPypi {
|
||||||
inherit pname version;
|
pname = old.pname;
|
||||||
|
inherit version;
|
||||||
sha256 = "6e84edecc3a82f90d44ddee2ee2a2630d4994b8471816e226d2b771cda7ac4ca";
|
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
|
in
|
||||||
py.pkgs.buildPythonApplication rec {
|
py.pkgs.buildPythonApplication rec {
|
||||||
pname = "netbox";
|
pname = "netbox";
|
||||||
version = "3.1.10";
|
version = "3.2.1";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "netbox-community";
|
owner = "netbox-community";
|
||||||
repo = pname;
|
repo = pname;
|
||||||
rev = "v${version}";
|
rev = "v${version}";
|
||||||
sha256 = "sha256-qREq4FJHHTA9Vm6f9kSfiYqur2omFmdsoZ4OdaPFcpU=";
|
sha256 = "sha256-iA0KIgaHQh0OsN/tXmTATIlvnf0aLRdjeQ6VkiR9VJ4=";
|
||||||
};
|
};
|
||||||
|
|
||||||
format = "other";
|
format = "other";
|
||||||
@ -57,6 +60,7 @@ py.pkgs.buildPythonApplication rec {
|
|||||||
patches = [
|
patches = [
|
||||||
# Allow setting the STATIC_ROOT from within the configuration and setting a custom redis URL
|
# Allow setting the STATIC_ROOT from within the configuration and setting a custom redis URL
|
||||||
./config.patch
|
./config.patch
|
||||||
|
./graphql-3_2_0.patch
|
||||||
];
|
];
|
||||||
|
|
||||||
propagatedBuildInputs = with py.pkgs; [
|
propagatedBuildInputs = with py.pkgs; [
|
||||||
@ -75,6 +79,7 @@ py.pkgs.buildPythonApplication rec {
|
|||||||
django-timezone-field
|
django-timezone-field
|
||||||
djangorestframework
|
djangorestframework
|
||||||
drf-yasg
|
drf-yasg
|
||||||
|
swagger-spec-validator # from drf-yasg[validation]
|
||||||
graphene-django
|
graphene-django
|
||||||
jinja2
|
jinja2
|
||||||
markdown
|
markdown
|
||||||
|
21
pkgs/servers/web-apps/netbox/graphql-3_2_0.patch
Normal file
21
pkgs/servers/web-apps/netbox/graphql-3_2_0.patch
Normal file
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user