mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
9856 base strawberry integration
This commit is contained in:
parent
5709bc3b2b
commit
3f2c21f005
@ -132,8 +132,12 @@ social-auth-core
|
||||
# https://github.com/python-social-auth/social-app-django/blob/master/CHANGELOG.md
|
||||
social-auth-app-django
|
||||
|
||||
# Enhanced Strawberry GraphQL integration with Django
|
||||
# https://github.com/blb-ventures/strawberry-django-plus/blob/main/CHANGELOG.md
|
||||
strawberry-graphql-django
|
||||
|
||||
# SVG image rendering (used for rack elevations)
|
||||
# hhttps://github.com/mozman/svgwrite/blob/master/NEWS.rst
|
||||
# https://github.com/mozman/svgwrite/blob/master/NEWS.rst
|
||||
svgwrite
|
||||
|
||||
# Tabular dataset library (for table-based exports)
|
||||
|
@ -1,31 +1,18 @@
|
||||
import graphene
|
||||
|
||||
from circuits.graphql.schema import CircuitsQuery
|
||||
from core.graphql.schema import CoreQuery
|
||||
from dcim.graphql.schema import DCIMQuery
|
||||
from extras.graphql.schema import ExtrasQuery
|
||||
from ipam.graphql.schema import IPAMQuery
|
||||
from netbox.registry import registry
|
||||
from tenancy.graphql.schema import TenancyQuery
|
||||
from users.graphql.schema import UsersQuery
|
||||
from virtualization.graphql.schema import VirtualizationQuery
|
||||
from wireless.graphql.schema import WirelessQuery
|
||||
import strawberry
|
||||
from strawberry_django.optimizer import DjangoOptimizerExtension
|
||||
|
||||
|
||||
class Query(
|
||||
UsersQuery,
|
||||
CircuitsQuery,
|
||||
CoreQuery,
|
||||
DCIMQuery,
|
||||
ExtrasQuery,
|
||||
IPAMQuery,
|
||||
TenancyQuery,
|
||||
VirtualizationQuery,
|
||||
WirelessQuery,
|
||||
*registry['plugins']['graphql_schemas'], # Append plugin schemas
|
||||
graphene.ObjectType
|
||||
):
|
||||
pass
|
||||
@strawberry.type
|
||||
class User:
|
||||
name: str
|
||||
age: int
|
||||
|
||||
|
||||
schema = graphene.Schema(query=Query, auto_camelcase=False)
|
||||
@strawberry.type
|
||||
class Query:
|
||||
@strawberry.field
|
||||
def user(self) -> User:
|
||||
return User(name="Patrick", age=100)
|
||||
|
||||
|
||||
schema = strawberry.Schema(query=Query)
|
||||
|
@ -361,7 +361,7 @@ INSTALLED_APPS = [
|
||||
'django_filters',
|
||||
'django_tables2',
|
||||
'django_prometheus',
|
||||
'graphene_django',
|
||||
'strawberry_django',
|
||||
'mptt',
|
||||
'rest_framework',
|
||||
'social_django',
|
||||
@ -385,7 +385,7 @@ INSTALLED_APPS = [
|
||||
|
||||
# Middleware
|
||||
MIDDLEWARE = [
|
||||
'graphiql_debug_toolbar.middleware.DebugToolbarMiddleware',
|
||||
"strawberry_django.middlewares.debug_toolbar.DebugToolbarMiddleware",
|
||||
'django_prometheus.middleware.PrometheusBeforeMiddleware',
|
||||
'corsheaders.middleware.CorsMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
|
@ -9,8 +9,8 @@ from account.views import LoginView, LogoutView
|
||||
from extras.plugins.urls import plugin_admin_patterns, plugin_patterns, plugin_api_patterns
|
||||
from netbox.api.views import APIRootView, StatusView
|
||||
from netbox.graphql.schema import schema
|
||||
from netbox.graphql.views import GraphQLView
|
||||
from netbox.views import HomeView, StaticMediaFailureView, SearchView, htmx
|
||||
from strawberry.django.views import GraphQLView
|
||||
from .admin import admin_site
|
||||
|
||||
_patterns = [
|
||||
@ -59,7 +59,7 @@ _patterns = [
|
||||
path('api/schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='api_redocs'),
|
||||
|
||||
# GraphQL
|
||||
path('graphql/', csrf_exempt(GraphQLView.as_view(graphiql=True, schema=schema)), name='graphql'),
|
||||
path('graphql/', GraphQLView.as_view(schema=schema), name='graphql'),
|
||||
|
||||
# Serving static media in Django to pipe it through LoginRequiredMiddleware
|
||||
path('media/<path:path>', serve, {'document_root': settings.MEDIA_ROOT}),
|
||||
|
@ -30,6 +30,7 @@ PyYAML==6.0.1
|
||||
sentry-sdk==1.29.2
|
||||
social-auth-app-django==5.2.0
|
||||
social-auth-core[openidconnect]==4.4.2
|
||||
strawberry-graphql-django==0.16.0
|
||||
svgwrite==1.4.3
|
||||
tablib==3.5.0
|
||||
tzdata==2023.3
|
||||
|
Loading…
Reference in New Issue
Block a user