From d3cb4c92e402e2e4abb6c4f2c61ace1a5c54dddc Mon Sep 17 00:00:00 2001 From: Brian Tiemann Date: Wed, 23 Oct 2024 10:16:09 -0400 Subject: [PATCH] Add note about select_related in graphql --- docs/development/adding-models.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/development/adding-models.md b/docs/development/adding-models.md index 59c3b0020..0bf020662 100644 --- a/docs/development/adding-models.md +++ b/docs/development/adding-models.md @@ -78,6 +78,8 @@ Create the following for each model: Create a GraphQL object type for the model in `graphql/types.py` by subclassing the appropriate class from `netbox.graphql.types`. +**Note:** GraphQL unit tests may fail citing null values on a non-nullable field if related objects are prefetched. You may need to fix this by setting the type annotation to be `= strawberry_django.field(select_related=["policy"])` or similar. + Also extend the schema class defined in `graphql/schema.py` with the individual object and object list fields per the established convention. ## 14. Add tests