Skip to content

Commit ec89a9b

Browse files
gellis713Griffin Ellis
andauthored
Fix parsing of extra_choices (#17691)
* Align strawberry resolver with expected return type * Align test data with expected representation of extra_choices in CustomFieldChoiceSet model --------- Co-authored-by: Griffin Ellis <[email protected]>
1 parent 2172ddd commit ec89a9b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

netbox/extras/graphql/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class CustomFieldType(ObjectType):
8484
class CustomFieldChoiceSetType(ObjectType):
8585

8686
choices_for: List[Annotated["CustomFieldType", strawberry.lazy('extras.graphql.types')]]
87-
extra_choices: List[str] | None
87+
extra_choices: List[List[str]] | None
8888

8989

9090
@strawberry_django.type(

netbox/extras/tests/test_api.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,18 @@ class CustomFieldChoiceSetTest(APIViewTestCases.APIViewTestCase):
244244
@classmethod
245245
def setUpTestData(cls):
246246
choice_sets = (
247-
CustomFieldChoiceSet(name='Choice Set 1', extra_choices=['1A', '1B', '1C', '1D', '1E']),
248-
CustomFieldChoiceSet(name='Choice Set 2', extra_choices=['2A', '2B', '2C', '2D', '2E']),
249-
CustomFieldChoiceSet(name='Choice Set 3', extra_choices=['3A', '3B', '3C', '3D', '3E']),
247+
CustomFieldChoiceSet(
248+
name='Choice Set 1',
249+
extra_choices=[['1A', '1A'], ['1B', '1B'], ['1C', '1C'], ['1D', '1D'], ['1E', '1E']],
250+
),
251+
CustomFieldChoiceSet(
252+
name='Choice Set 2',
253+
extra_choices=[['2A', '2A'], ['2B', '2B'], ['2C', '2C'], ['2D', '2D'], ['2E', '2E']],
254+
),
255+
CustomFieldChoiceSet(
256+
name='Choice Set 3',
257+
extra_choices=[['3A', '3A'], ['3B', '3B'], ['3C', '3C'], ['3D', '3D'], ['3E', '3E']],
258+
),
250259
)
251260
CustomFieldChoiceSet.objects.bulk_create(choice_sets)
252261

0 commit comments

Comments
 (0)