From 2ef21f7097107faedfebb607ffe5ac2eae2228ea Mon Sep 17 00:00:00 2001 From: Grische <2787581+grische@users.noreply.github.com> Date: Wed, 25 Feb 2026 22:17:04 +0100 Subject: [PATCH] Fixes: #21456 - Improve config_context rendering with GraphQL (#21495) --- netbox/extras/graphql/mixins.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/netbox/extras/graphql/mixins.py b/netbox/extras/graphql/mixins.py index 719d95f79..96f9719a3 100644 --- a/netbox/extras/graphql/mixins.py +++ b/netbox/extras/graphql/mixins.py @@ -22,7 +22,19 @@ if TYPE_CHECKING: @strawberry.type class ConfigContextMixin: - @strawberry_django.field + @classmethod + def get_queryset(cls, queryset, info: Info, **kwargs): + queryset = super().get_queryset(queryset, info, **kwargs) + + # If `config_context` is requested, call annotate_config_context_data() on the queryset + selected = {f.name for f in info.selected_fields[0].selections} + if 'config_context' in selected and hasattr(queryset, 'annotate_config_context_data'): + return queryset.annotate_config_context_data() + + return queryset + + # Ensure `local_context_data` is fetched when `config_context` is requested + @strawberry_django.field(only=['local_context_data']) def config_context(self) -> strawberry.scalars.JSON: return self.get_config_context()