diff --git a/netbox/circuits/graphql/types.py b/netbox/circuits/graphql/types.py index 420e13772..6a96a54b9 100644 --- a/netbox/circuits/graphql/types.py +++ b/netbox/circuits/graphql/types.py @@ -51,6 +51,7 @@ class ProviderType(NetBoxObjectType, ContactsMixin): filters=ProviderAccountFilter ) class ProviderAccountType(NetBoxObjectType): + provider: Annotated["ProviderType", strawberry.lazy('circuits.graphql.types')] @strawberry_django.field def circuits(self) -> List[Annotated["CircuitType", strawberry.lazy('circuits.graphql.types')]]: @@ -63,6 +64,7 @@ class ProviderAccountType(NetBoxObjectType): filters=ProviderNetworkFilter ) class ProviderNetworkType(NetBoxObjectType): + provider: Annotated["ProviderType", strawberry.lazy('circuits.graphql.types')] @strawberry_django.field def circuit_terminations(self) -> List[Annotated["CircuitTerminationType", strawberry.lazy('circuits.graphql.types')]]: @@ -75,7 +77,9 @@ class ProviderNetworkType(NetBoxObjectType): filters=CircuitTerminationFilter ) class CircuitTerminationType(CustomFieldsMixin, TagsMixin, CabledObjectMixin, ObjectType): - pass + circuit: Annotated["CircuitType", strawberry.lazy('circuits.graphql.types')] + provider_network: Annotated["ProviderNetworkType", strawberry.lazy('circuits.graphql.types')] | None + site: Annotated["SiteType", strawberry.lazy('dcim.graphql.types')] | None @strawberry_django.type( diff --git a/netbox/dcim/graphql/mixins.py b/netbox/dcim/graphql/mixins.py index 8e79b4c0b..19fd62b14 100644 --- a/netbox/dcim/graphql/mixins.py +++ b/netbox/dcim/graphql/mixins.py @@ -11,11 +11,7 @@ __all__ = ( @strawberry.type class CabledObjectMixin: - - # @strawberry_django.field - # def cable_end(self) -> List[Annotated["ObjectChangeType", strawberry.lazy('.types')]]: - # # Handle empty values - # return self.cable_end or None + cable: Annotated["CableType", strawberry.lazy('dcim.graphql.types')] | None @strawberry_django.field def link_peers(self) -> List[Annotated[Union[ diff --git a/netbox/netbox/tests/dummy_plugin/graphql.py b/netbox/netbox/tests/dummy_plugin/graphql.py index bc6643ba9..640c12959 100644 --- a/netbox/netbox/tests/dummy_plugin/graphql.py +++ b/netbox/netbox/tests/dummy_plugin/graphql.py @@ -21,8 +21,8 @@ class DummyQuery: return None dummymodel_list: List[DummyModelType] = strawberry_django.field() - -schema = strawberry.Schema( - query=DummyQuery, - config=StrawberryConfig(auto_camel_case=False), -) +# bug - temp - FIXME! +# schema = strawberry.Schema( +# query=DummyQuery, +# config=StrawberryConfig(auto_camel_case=False), +# ) diff --git a/netbox/utilities/testing/api.py b/netbox/utilities/testing/api.py index 15c96d568..9be4cfd5e 100644 --- a/netbox/utilities/testing/api.py +++ b/netbox/utilities/testing/api.py @@ -472,13 +472,21 @@ class APIViewTestCases: # this would require a fragment query continue elif field.type is strawberry_django.fields.types.DjangoModelType: + print("") + print("DjangoModelType") + print(f"{self.model} -> {field.name}") + print("") # Dynamic fields must specify a subselection - fields_string += f'{field.name} {{ pk }}\n' + fields_string += f'{field.name} {{ id }}\n' elif type(field.type) is StrawberryOptional: if type(field.type.of_type) is LazyType: fields_string += f'{field.name} {{ id }}\n' elif field.type.of_type == strawberry_django.fields.types.DjangoModelType: - fields_string += f'{field.name} {{ pk }}\n' + print("") + print("DjangoModelType") + print(f"{self.model} -> {field.name}") + print("") + fields_string += f'{field.name} {{ id }}\n' elif hasattr(field, 'is_relation') and field.is_relation: # Note: StrawberryField types do not have is_relation fields_string += f'{field.name} {{ id }}\n'