mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
15809 Mark unions as nullable in GraphQL where appropriate (#15824)
* 15809 mark unions as nullable where appropriate * 15809 fix tests * 15809 fix tests
This commit is contained in:
@ -130,7 +130,7 @@ class CableTerminationType(NetBoxObjectType):
|
|||||||
Annotated["PowerOutletType", strawberry.lazy('dcim.graphql.types')],
|
Annotated["PowerOutletType", strawberry.lazy('dcim.graphql.types')],
|
||||||
Annotated["PowerPortType", strawberry.lazy('dcim.graphql.types')],
|
Annotated["PowerPortType", strawberry.lazy('dcim.graphql.types')],
|
||||||
Annotated["RearPortType", strawberry.lazy('dcim.graphql.types')],
|
Annotated["RearPortType", strawberry.lazy('dcim.graphql.types')],
|
||||||
], strawberry.union("CableTerminationTerminationType")]
|
], strawberry.union("CableTerminationTerminationType")] | None
|
||||||
|
|
||||||
|
|
||||||
@strawberry_django.type(
|
@strawberry_django.type(
|
||||||
@ -302,7 +302,7 @@ class InventoryItemTemplateType(ComponentTemplateType):
|
|||||||
Annotated["PowerOutletType", strawberry.lazy('dcim.graphql.types')],
|
Annotated["PowerOutletType", strawberry.lazy('dcim.graphql.types')],
|
||||||
Annotated["PowerPortType", strawberry.lazy('dcim.graphql.types')],
|
Annotated["PowerPortType", strawberry.lazy('dcim.graphql.types')],
|
||||||
Annotated["RearPortType", strawberry.lazy('dcim.graphql.types')],
|
Annotated["RearPortType", strawberry.lazy('dcim.graphql.types')],
|
||||||
], strawberry.union("InventoryItemTemplateComponentType")]
|
], strawberry.union("InventoryItemTemplateComponentType")] | None
|
||||||
|
|
||||||
|
|
||||||
@strawberry_django.type(
|
@strawberry_django.type(
|
||||||
@ -431,7 +431,7 @@ class InventoryItemType(ComponentType):
|
|||||||
Annotated["PowerOutletType", strawberry.lazy('dcim.graphql.types')],
|
Annotated["PowerOutletType", strawberry.lazy('dcim.graphql.types')],
|
||||||
Annotated["PowerPortType", strawberry.lazy('dcim.graphql.types')],
|
Annotated["PowerPortType", strawberry.lazy('dcim.graphql.types')],
|
||||||
Annotated["RearPortType", strawberry.lazy('dcim.graphql.types')],
|
Annotated["RearPortType", strawberry.lazy('dcim.graphql.types')],
|
||||||
], strawberry.union("InventoryItemComponentType")]
|
], strawberry.union("InventoryItemComponentType")] | None
|
||||||
|
|
||||||
|
|
||||||
@strawberry_django.type(
|
@strawberry_django.type(
|
||||||
|
@ -133,7 +133,7 @@ class IPAddressType(NetBoxObjectType, BaseIPAddressFamilyType):
|
|||||||
Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')],
|
Annotated["InterfaceType", strawberry.lazy('dcim.graphql.types')],
|
||||||
Annotated["FHRPGroupType", strawberry.lazy('ipam.graphql.types')],
|
Annotated["FHRPGroupType", strawberry.lazy('ipam.graphql.types')],
|
||||||
Annotated["VMInterfaceType", strawberry.lazy('virtualization.graphql.types')],
|
Annotated["VMInterfaceType", strawberry.lazy('virtualization.graphql.types')],
|
||||||
], strawberry.union("IPAddressAssignmentType")]:
|
], strawberry.union("IPAddressAssignmentType")] | None:
|
||||||
return self.assigned_object
|
return self.assigned_object
|
||||||
|
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ class VLANGroupType(OrganizationalObjectType):
|
|||||||
Annotated["RegionType", strawberry.lazy('dcim.graphql.types')],
|
Annotated["RegionType", strawberry.lazy('dcim.graphql.types')],
|
||||||
Annotated["SiteType", strawberry.lazy('dcim.graphql.types')],
|
Annotated["SiteType", strawberry.lazy('dcim.graphql.types')],
|
||||||
Annotated["SiteGroupType", strawberry.lazy('dcim.graphql.types')],
|
Annotated["SiteGroupType", strawberry.lazy('dcim.graphql.types')],
|
||||||
], strawberry.union("VLANGroupScopeType")]:
|
], strawberry.union("VLANGroupScopeType")] | None:
|
||||||
return self.scope
|
return self.scope
|
||||||
|
|
||||||
|
|
||||||
|
@ -469,6 +469,9 @@ class APIViewTestCases:
|
|||||||
elif type(field.type) is StrawberryUnion:
|
elif type(field.type) is StrawberryUnion:
|
||||||
# this would require a fragment query
|
# this would require a fragment query
|
||||||
continue
|
continue
|
||||||
|
elif type(field.type) is StrawberryOptional and type(field.type.of_type) is StrawberryUnion:
|
||||||
|
# this would require a fragment query
|
||||||
|
continue
|
||||||
elif type(field.type) is StrawberryOptional and type(field.type.of_type) is LazyType:
|
elif type(field.type) is StrawberryOptional and type(field.type.of_type) is LazyType:
|
||||||
fields_string += f'{field.name} {{ id }}\n'
|
fields_string += f'{field.name} {{ id }}\n'
|
||||||
elif hasattr(field, 'is_relation') and field.is_relation:
|
elif hasattr(field, 'is_relation') and field.is_relation:
|
||||||
|
Reference in New Issue
Block a user