mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 16:26:09 -06:00
9478 fix feature merge
This commit is contained in:
commit
9c55e43978
@ -21,6 +21,7 @@ A new `PluginMenu` class has been introduced, which enables a plugin to inject a
|
|||||||
* [#9654](https://github.com/netbox-community/netbox/issues/9654) - Add `weight` field to racks, device types, and module types
|
* [#9654](https://github.com/netbox-community/netbox/issues/9654) - Add `weight` field to racks, device types, and module types
|
||||||
* [#9892](https://github.com/netbox-community/netbox/issues/9892) - Add optional `name` field for FHRP groups
|
* [#9892](https://github.com/netbox-community/netbox/issues/9892) - Add optional `name` field for FHRP groups
|
||||||
* [#10348](https://github.com/netbox-community/netbox/issues/10348) - Add decimal custom field type
|
* [#10348](https://github.com/netbox-community/netbox/issues/10348) - Add decimal custom field type
|
||||||
|
* [#10556](https://github.com/netbox-community/netbox/issues/10556) - Include a `display` field in all GraphQL object types
|
||||||
|
|
||||||
### Plugins API
|
### Plugins API
|
||||||
|
|
||||||
@ -46,3 +47,7 @@ A new `PluginMenu` class has been introduced, which enables a plugin to inject a
|
|||||||
* Added optional `weight` and `weight_unit` fields
|
* Added optional `weight` and `weight_unit` fields
|
||||||
* ipam.FHRPGroup
|
* ipam.FHRPGroup
|
||||||
* Added optional `name` field
|
* Added optional `name` field
|
||||||
|
|
||||||
|
### GraphQL API Changes
|
||||||
|
|
||||||
|
* All object types now include a `display` field
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from graphene import Scalar
|
from graphene import Scalar
|
||||||
from graphql.language import ast
|
from graphql.language import ast
|
||||||
from graphql.type.scalars import MAX_INT, MIN_INT
|
from graphene.types.scalars import MAX_INT, MIN_INT
|
||||||
|
|
||||||
|
|
||||||
class BigInt(Scalar):
|
class BigInt(Scalar):
|
||||||
|
@ -12,12 +12,12 @@ from wireless.graphql.schema import WirelessQuery
|
|||||||
|
|
||||||
|
|
||||||
class Query(
|
class Query(
|
||||||
|
UsersQuery,
|
||||||
CircuitsQuery,
|
CircuitsQuery,
|
||||||
DCIMQuery,
|
DCIMQuery,
|
||||||
ExtrasQuery,
|
ExtrasQuery,
|
||||||
IPAMQuery,
|
IPAMQuery,
|
||||||
TenancyQuery,
|
TenancyQuery,
|
||||||
UsersQuery,
|
|
||||||
VirtualizationQuery,
|
VirtualizationQuery,
|
||||||
WirelessQuery,
|
WirelessQuery,
|
||||||
*registry['plugins']['graphql_schemas'], # Append plugin schemas
|
*registry['plugins']['graphql_schemas'], # Append plugin schemas
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import graphene
|
import graphene
|
||||||
|
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from extras.graphql.mixins import (
|
from extras.graphql.mixins import (
|
||||||
ChangelogMixin,
|
ChangelogMixin,
|
||||||
@ -24,6 +25,7 @@ class BaseObjectType(DjangoObjectType):
|
|||||||
"""
|
"""
|
||||||
Base GraphQL object type for all NetBox objects. Restricts the model queryset to enforce object permissions.
|
Base GraphQL object type for all NetBox objects. Restricts the model queryset to enforce object permissions.
|
||||||
"""
|
"""
|
||||||
|
display = graphene.String()
|
||||||
class_type = graphene.String()
|
class_type = graphene.String()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -34,6 +36,9 @@ class BaseObjectType(DjangoObjectType):
|
|||||||
# Enforce object permissions on the queryset
|
# Enforce object permissions on the queryset
|
||||||
return queryset.restrict(info.context.user, 'view')
|
return queryset.restrict(info.context.user, 'view')
|
||||||
|
|
||||||
|
def resolve_display(parent, info, **kwargs):
|
||||||
|
return str(parent)
|
||||||
|
|
||||||
def resolve_class_type(parent, info, **kwargs):
|
def resolve_class_type(parent, info, **kwargs):
|
||||||
return parent.__class__.__name__
|
return parent.__class__.__name__
|
||||||
|
|
||||||
|
@ -467,6 +467,7 @@ class APIViewTestCases:
|
|||||||
return query
|
return query
|
||||||
|
|
||||||
@override_settings(LOGIN_REQUIRED=True)
|
@override_settings(LOGIN_REQUIRED=True)
|
||||||
|
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*', 'auth.user'])
|
||||||
def test_graphql_get_object(self):
|
def test_graphql_get_object(self):
|
||||||
url = reverse('graphql')
|
url = reverse('graphql')
|
||||||
field_name = self._get_graphql_base_name()
|
field_name = self._get_graphql_base_name()
|
||||||
@ -492,6 +493,7 @@ class APIViewTestCases:
|
|||||||
self.assertNotIn('errors', data)
|
self.assertNotIn('errors', data)
|
||||||
|
|
||||||
@override_settings(LOGIN_REQUIRED=True)
|
@override_settings(LOGIN_REQUIRED=True)
|
||||||
|
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*', 'auth.user'])
|
||||||
def test_graphql_list_objects(self):
|
def test_graphql_list_objects(self):
|
||||||
url = reverse('graphql')
|
url = reverse('graphql')
|
||||||
field_name = f'{self._get_graphql_base_name()}_list'
|
field_name = f'{self._get_graphql_base_name()}_list'
|
||||||
|
@ -15,7 +15,7 @@ django-taggit==3.0.0
|
|||||||
django-timezone-field==5.0
|
django-timezone-field==5.0
|
||||||
djangorestframework==3.14.0
|
djangorestframework==3.14.0
|
||||||
drf-yasg[validation]==1.21.4
|
drf-yasg[validation]==1.21.4
|
||||||
graphene-django==2.15.0
|
graphene-django==3.0.0
|
||||||
gunicorn==20.1.0
|
gunicorn==20.1.0
|
||||||
Jinja2==3.1.2
|
Jinja2==3.1.2
|
||||||
Markdown==3.3.7
|
Markdown==3.3.7
|
||||||
|
Loading…
Reference in New Issue
Block a user