9856 fix docs

This commit is contained in:
Arthur 2024-03-11 08:50:56 -07:00
parent 36e6f0d28e
commit 916722780c
2 changed files with 22 additions and 14 deletions

View File

@ -8,23 +8,32 @@ A plugin can extend NetBox's GraphQL API by registering its own schema class. By
```python ```python
# graphql.py # graphql.py
import graphene from typing import List
from netbox.graphql.types import NetBoxObjectType import strawberry
from netbox.graphql.fields import ObjectField, ObjectListField import strawberry_django
from . import filtersets, models
class MyModelType(NetBoxObjectType): from . import models
class Meta:
model = models.MyModel
fields = '__all__'
filterset_class = filtersets.MyModelFilterSet
class MyQuery(graphene.ObjectType): @strawberry_django.type(
mymodel = ObjectField(MyModelType) models.MyModel,
mymodel_list = ObjectListField(MyModelType) fields='__all__',
)
class MyModelType:
pass
schema = MyQuery
@strawberry.type
class MyQuery:
@strawberry.field
def dummymodel(self, id: int) -> DummyModelType:
return None
dummymodel_list: List[DummyModelType] = strawberry_django.field()
schema = [
MyQuery,
]
``` ```
## GraphQL Objects ## GraphQL Objects

View File

@ -1,7 +1,6 @@
from typing import List from typing import List
import strawberry import strawberry
import strawberry_django import strawberry_django
from strawberry.schema.config import StrawberryConfig
from . import models from . import models