diff --git a/netbox/circuits/graphql/schema.py b/netbox/circuits/graphql/schema.py index 7b0356920..48eff5413 100644 --- a/netbox/circuits/graphql/schema.py +++ b/netbox/circuits/graphql/schema.py @@ -8,20 +8,32 @@ from .types import * @strawberry.type class CircuitsQuery: - circuit: CircuitType = strawberry_django.field() + @strawberry.field + def circuit(self, id: int) -> CircuitType: + return models.Circuit.objects.get(id=id) circuit_list: List[CircuitType] = strawberry_django.field() - circuit_termination: CircuitTerminationType = strawberry_django.field() + @strawberry.field + def circuit_termination(self, id: int) -> CircuitTerminationType: + return models.CircuitTermination.objects.get(id=id) circuit_termination_list: List[CircuitTerminationType] = strawberry_django.field() - circuit_type: CircuitTypeType = strawberry_django.field() + @strawberry.field + def circuit_type(self, id: int) -> CircuitTypeType: + return models.CircuitType.objects.get(id=id) circuit_type_list: List[CircuitTypeType] = strawberry_django.field() - provider: ProviderType = strawberry_django.field() + @strawberry.field + def provider(self, id: int) -> ProviderType: + return models.Provider.objects.get(id=id) provider_list: List[ProviderType] = strawberry_django.field() - provider_account: ProviderAccountType = strawberry_django.field() + @strawberry.field + def provider_account(self, id: int) -> ProviderAccountType: + return models.ProviderAccount.objects.get(id=id) provider_account_list: List[ProviderAccountType] = strawberry_django.field() - provider_network: ProviderNetworkType = strawberry_django.field() + @strawberry.field + def provider_network(self, id: int) -> ProviderNetworkType: + return models.ProviderNetwork.objects.get(id=id) provider_network_list: List[ProviderNetworkType] = strawberry_django.field() diff --git a/netbox/core/graphql/schema.py b/netbox/core/graphql/schema.py index 7118da11b..3dc4c7806 100644 --- a/netbox/core/graphql/schema.py +++ b/netbox/core/graphql/schema.py @@ -8,8 +8,12 @@ from .types import * @strawberry.type class CoreQuery: - data_file: DataFileType = strawberry_django.field() + @strawberry.field + def data_file(self, id: int) -> DataFileType: + return models.DataFile.objects.get(id=id) data_file_list: List[DataFileType] = strawberry_django.field() - data_source: DataSourceType = strawberry_django.field() + @strawberry.field + def data_source(self, id: int) -> DataSourceType: + return models.DataSource.objects.get(id=id) data_source_list: List[DataSourceType] = strawberry_django.field() diff --git a/netbox/dcim/graphql/schema.py b/netbox/dcim/graphql/schema.py index 41a273868..9dc3388b7 100644 --- a/netbox/dcim/graphql/schema.py +++ b/netbox/dcim/graphql/schema.py @@ -8,122 +8,202 @@ from .types import * @strawberry.type class DCIMQuery: - cable: CableType = strawberry_django.field() + @strawberry.field + def cable(self, id: int) -> CableType: + return models.Cable.objects.get(id=id) cable_list: List[CableType] = strawberry_django.field() - console_port: ConsolePortType = strawberry_django.field() + @strawberry.field + def console_port(self, id: int) -> ConsolePortType: + return models.ConsolePort.objects.get(id=id) console_port_list: List[ConsolePortType] = strawberry_django.field() - console_port_template: ConsolePortTemplateType = strawberry_django.field() + @strawberry.field + def console_port_template(self, id: int) -> ConsolePortTemplateType: + return models.ConsolePortTemplate.objects.get(id=id) console_port_template_list: List[ConsolePortTemplateType] = strawberry_django.field() - console_server_port: ConsoleServerPortType = strawberry_django.field() + @strawberry.field + def console_server_port(self, id: int) -> ConsoleServerPortType: + return models.ConsoleServerPort.objects.get(id=id) console_server_port_list: List[ConsoleServerPortType] = strawberry_django.field() - console_server_port_template: ConsoleServerPortTemplateType = strawberry_django.field() + @strawberry.field + def console_server_port_template(self, id: int) -> ConsoleServerPortTemplateType: + return models.ConsoleServerPortTemplate.objects.get(id=id) console_server_port_template_list: List[ConsoleServerPortTemplateType] = strawberry_django.field() - device: DeviceType = strawberry_django.field() + @strawberry.field + def device(self, id: int) -> DeviceType: + return models.Device.objects.get(id=id) device_list: List[DeviceType] = strawberry_django.field() - device_bay: DeviceBayType = strawberry_django.field() + @strawberry.field + def device_bay(self, id: int) -> DeviceBayType: + return models.DeviceBay.objects.get(id=id) device_bay_list: List[DeviceBayType] = strawberry_django.field() - device_bay_template: DeviceBayTemplateType = strawberry_django.field() + @strawberry.field + def device_bay_template(self, id: int) -> DeviceBayTemplateType: + return models.DeviceBayTemplate.objects.get(id=id) device_bay_template_list: List[DeviceBayTemplateType] = strawberry_django.field() - device_role: DeviceRoleType = strawberry_django.field() + @strawberry.field + def device_role(self, id: int) -> DeviceRoleType: + return models.DeviceRole.objects.get(id=id) device_role_list: List[DeviceRoleType] = strawberry_django.field() - device_type: DeviceTypeType = strawberry_django.field() + @strawberry.field + def device_type(self, id: int) -> DeviceTypeType: + return models.DeviceType.objects.get(id=id) device_type_list: List[DeviceTypeType] = strawberry_django.field() - front_port: FrontPortType = strawberry_django.field() + @strawberry.field + def front_port(self, id: int) -> FrontPortType: + return models.FrontPort.objects.get(id=id) front_port_list: List[FrontPortType] = strawberry_django.field() - front_port_template: FrontPortTemplateType = strawberry_django.field() + @strawberry.field + def front_port_template(self, id: int) -> FrontPortTemplateType: + return models.FrontPortTemplate.objects.get(id=id) front_port_template_list: List[FrontPortTemplateType] = strawberry_django.field() - interface: InterfaceType = strawberry_django.field() + @strawberry.field + def interface(self, id: int) -> InterfaceType: + return models.Interface.objects.get(id=id) interface_list: List[InterfaceType] = strawberry_django.field() - interface_template: InterfaceTemplateType = strawberry_django.field() + @strawberry.field + def interface_template(self, id: int) -> InterfaceTemplateType: + return models.InterfaceTemplate.objects.get(id=id) interface_template_list: List[InterfaceTemplateType] = strawberry_django.field() - inventory_item: InventoryItemType = strawberry_django.field() + @strawberry.field + def inventory_item(self, id: int) -> InventoryItemType: + return models.InventoryItem.objects.get(id=id) inventory_item_list: List[InventoryItemType] = strawberry_django.field() - inventory_item_role: InventoryItemRoleType = strawberry_django.field() + @strawberry.field + def inventory_item_role(self, id: int) -> InventoryItemRoleType: + return models.InventoryItemRole.objects.get(id=id) inventory_item_role_list: List[InventoryItemRoleType] = strawberry_django.field() - inventory_item_template: InventoryItemTemplateType = strawberry_django.field() + @strawberry.field + def inventory_item_template(self, id: int) -> InventoryItemTemplateType: + return models.InventoryItemTemplate.objects.get(id=id) inventory_item_template_list: List[InventoryItemTemplateType] = strawberry_django.field() - location: LocationType = strawberry_django.field() + @strawberry.field + def location(self, id: int) -> LocationType: + return models.Location.objects.get(id=id) location_list: List[LocationType] = strawberry_django.field() - manufacturer: ManufacturerType = strawberry_django.field() + @strawberry.field + def manufacturer(self, id: int) -> ManufacturerType: + return models.Manufacturer.objects.get(id=id) manufacturer_list: List[ManufacturerType] = strawberry_django.field() - module: ModuleType = strawberry_django.field() + @strawberry.field + def module(self, id: int) -> ModuleType: + return models.Module.objects.get(id=id) module_list: List[ModuleType] = strawberry_django.field() - module_bay: ModuleBayType = strawberry_django.field() + @strawberry.field + def module_bay(self, id: int) -> ModuleBayType: + return models.ModuleBay.objects.get(id=id) module_bay_list: List[ModuleBayType] = strawberry_django.field() - module_bay_template: ModuleBayTemplateType = strawberry_django.field() + @strawberry.field + def module_bay_template(self, id: int) -> ModuleBayTemplateType: + return models.ModuleBayTemplate.objects.get(id=id) module_bay_template_list: List[ModuleBayTemplateType] = strawberry_django.field() - module_type: ModuleTypeType = strawberry_django.field() + @strawberry.field + def module_type(self, id: int) -> ModuleTypeType: + return models.ModuleType.objects.get(id=id) module_type_list: List[ModuleTypeType] = strawberry_django.field() - platform: PlatformType = strawberry_django.field() + @strawberry.field + def platform(self, id: int) -> PlatformType: + return models.Platform.objects.get(id=id) platform_list: List[PlatformType] = strawberry_django.field() - power_feed: PowerFeedType = strawberry_django.field() + @strawberry.field + def power_feed(self, id: int) -> PowerFeedType: + return models.PowerFeed.objects.get(id=id) power_feed_list: List[PowerFeedType] = strawberry_django.field() - power_outlet: PowerOutletType = strawberry_django.field() + @strawberry.field + def power_outlet(self, id: int) -> PowerOutletType: + return models.PowerOutlet.objects.get(id=id) power_outlet_list: List[PowerOutletType] = strawberry_django.field() - power_outlet_template: PowerOutletTemplateType = strawberry_django.field() + @strawberry.field + def power_outlet_template(self, id: int) -> PowerOutletTemplateType: + return models.PowerOutletTemplate.objects.get(id=id) power_outlet_template_list: List[PowerOutletTemplateType] = strawberry_django.field() - power_panel: PowerPanelType = strawberry_django.field() + @strawberry.field + def power_panel(self, id: int) -> PowerPanelType: + return models.PowerPanel.objects.get(id=id) power_panel_list: List[PowerPanelType] = strawberry_django.field() - power_port: PowerPortType = strawberry_django.field() + @strawberry.field + def power_port(self, id: int) -> PowerPortType: + return models.PowerPort.objects.get(id=id) power_port_list: List[PowerPortType] = strawberry_django.field() - power_port_template: PowerPortTemplateType = strawberry_django.field() + @strawberry.field + def power_port_template(self, id: int) -> PowerPortTemplateType: + return models.PowerPortTemplate.objects.get(id=id) power_port_template_list: List[PowerPortTemplateType] = strawberry_django.field() - rack: RackType = strawberry_django.field() + @strawberry.field + def rack(self, id: int) -> RackType: + return models.Rack.objects.get(id=id) rack_list: List[RackType] = strawberry_django.field() - rack_reservation: RackReservationType = strawberry_django.field() + @strawberry.field + def rack_reservation(self, id: int) -> RackReservationType: + return models.RackReservation.objects.get(id=id) rack_reservation_list: List[RackReservationType] = strawberry_django.field() - rack_role: RackRoleType = strawberry_django.field() + @strawberry.field + def rack_role(self, id: int) -> RackRoleType: + return models.RackRole.objects.get(id=id) rack_role_list: List[RackRoleType] = strawberry_django.field() - rear_port: RearPortType = strawberry_django.field() + @strawberry.field + def rear_port(self, id: int) -> RearPortType: + return models.RearPort.objects.get(id=id) rear_port_list: List[RearPortType] = strawberry_django.field() - rear_port_template: RearPortTemplateType = strawberry_django.field() + @strawberry.field + def rear_port_template(self, id: int) -> RearPortTemplateType: + return models.RearPortTemplate.objects.get(id=id) rear_port_template_list: List[RearPortTemplateType] = strawberry_django.field() - region: RegionType = strawberry_django.field() + @strawberry.field + def region(self, id: int) -> RegionType: + return models.Region.objects.get(id=id) region_list: List[RegionType] = strawberry_django.field() - site: SiteType = strawberry_django.field() + @strawberry.field + def site(self, id: int) -> SiteType: + return models.Site.objects.get(id=id) site_list: List[SiteType] = strawberry_django.field() - site_group: SiteGroupType = strawberry_django.field() + @strawberry.field + def site_group(self, id: int) -> SiteGroupType: + return models.SiteGroup.objects.get(id=id) site_group_list: List[SiteGroupType] = strawberry_django.field() - virtual_chassis: VirtualChassisType = strawberry_django.field() + @strawberry.field + def virtual_chassis(self, id: int) -> VirtualChassisType: + return models.VirtualChassis.objects.get(id=id) virtual_chassis_list: List[VirtualChassisType] = strawberry_django.field() - virtual_device_context: VirtualDeviceContextType = strawberry_django.field() + @strawberry.field + def virtual_device_context(self, id: int) -> VirtualDeviceContextType: + return models.VirtualDeviceContext.objects.get(id=id) virtual_device_context_list: List[VirtualDeviceContextType] = strawberry_django.field() diff --git a/netbox/extras/graphql/schema.py b/netbox/extras/graphql/schema.py index 14069021b..0f1e99c47 100644 --- a/netbox/extras/graphql/schema.py +++ b/netbox/extras/graphql/schema.py @@ -8,38 +8,62 @@ from .types import * @strawberry.type class ExtrasQuery: - config_context: ConfigContextType = strawberry_django.field() + @strawberry.field + def config_context(self, id: int) -> ConfigContextType: + return models.ConfigContext.objects.get(id=id) config_context_list: List[ConfigContextType] = strawberry_django.field() - config_template: ConfigTemplateType = strawberry_django.field() + @strawberry.field + def config_template(self, id: int) -> ConfigTemplateType: + return models.ConfigTemplate.objects.get(id=id) config_template_list: List[ConfigTemplateType] = strawberry_django.field() - custom_field: CustomFieldType = strawberry_django.field() + @strawberry.field + def custom_field(self, id: int) -> CustomFieldType: + return models.CustomField.objects.get(id=id) custom_field_list: List[CustomFieldType] = strawberry_django.field() - custom_field_choice_set: CustomFieldChoiceSetType = strawberry_django.field() + @strawberry.field + def custom_field_choice_set(self, id: int) -> CustomFieldChoiceSetType: + return models.CustomFieldChoiceSet.objects.get(id=id) custom_field_choice_set_list: List[CustomFieldChoiceSetType] = strawberry_django.field() - custom_link: CustomLinkType = strawberry_django.field() + @strawberry.field + def custom_link(self, id: int) -> CustomLinkType: + return models.CustomLink.objects.get(id=id) custom_link_list: List[CustomLinkType] = strawberry_django.field() - export_template: ExportTemplateType = strawberry_django.field() + @strawberry.field + def export_template(self, id: int) -> ExportTemplateType: + return models.ExportTemplate.objects.get(id=id) export_template_list: List[ExportTemplateType] = strawberry_django.field() - image_attachment: ImageAttachmentType = strawberry_django.field() + @strawberry.field + def image_attachment(self, id: int) -> ImageAttachmentType: + return models.ImageAttachment.objects.get(id=id) image_attachment_list: List[ImageAttachmentType] = strawberry_django.field() - saved_filter: SavedFilterType = strawberry_django.field() + @strawberry.field + def saved_filter(self, id: int) -> SavedFilterType: + return models.SavedFilter.objects.get(id=id) saved_filter_list: List[SavedFilterType] = strawberry_django.field() - journal_entry: JournalEntryType = strawberry_django.field() + @strawberry.field + def journal_entry(self, id: int) -> JournalEntryType: + return models.JournalEntry.objects.get(id=id) journal_entry_list: List[JournalEntryType] = strawberry_django.field() - tag: TagType = strawberry_django.field() + @strawberry.field + def tag(self, id: int) -> TagType: + return models.Tag.objects.get(id=id) tag_list: List[TagType] = strawberry_django.field() - webhook: WebhookType = strawberry_django.field() + @strawberry.field + def webhook(self, id: int) -> WebhookType: + return models.Webhook.objects.get(id=id) webhook_list: List[WebhookType] = strawberry_django.field() - event_rule: EventRuleType = strawberry_django.field() + @strawberry.field + def event_rule(self, id: int) -> EventRuleType: + return models.EventRule.objects.get(id=id) event_rule_list: List[EventRuleType] = strawberry_django.field() diff --git a/netbox/ipam/graphql/schema.py b/netbox/ipam/graphql/schema.py index 230520f5d..29fff5a7b 100644 --- a/netbox/ipam/graphql/schema.py +++ b/netbox/ipam/graphql/schema.py @@ -8,50 +8,82 @@ from .types import * @strawberry.type class IPAMQuery: - asn: ASNType = strawberry_django.field() + @strawberry.field + def asn(self, id: int) -> ASNType: + return models.ASN.objects.get(id=id) asn_list: List[ASNType] = strawberry_django.field() - asn_range: ASNRangeType = strawberry_django.field() + @strawberry.field + def asn_range(self, id: int) -> ASNRangeType: + return models.ASNRange.objects.get(id=id) asn_range_list: List[ASNRangeType] = strawberry_django.field() - aggregate: AggregateType = strawberry_django.field() + @strawberry.field + def aggregate(self, id: int) -> AggregateType: + return models.Aggregate.objects.get(id=id) aggregate_list: List[AggregateType] = strawberry_django.field() - ip_address: IPAddressType = strawberry_django.field() + @strawberry.field + def ip_address(self, id: int) -> IPAddressType: + return models.IPAddress.objects.get(id=id) ip_address_list: List[IPAddressType] = strawberry_django.field() - ip_range: IPRangeType = strawberry_django.field() + @strawberry.field + def ip_range(self, id: int) -> IPRangeType: + return models.IPRange.objects.get(id=id) ip_range_list: List[IPRangeType] = strawberry_django.field() - prefix: PrefixType = strawberry_django.field() + @strawberry.field + def prefix(self, id: int) -> PrefixType: + return models.Prefix.objects.get(id=id) prefix_list: List[PrefixType] = strawberry_django.field() - rir: RIRType = strawberry_django.field() + @strawberry.field + def rir(self, id: int) -> RIRType: + return models.RIR.objects.get(id=id) rir_list: List[RIRType] = strawberry_django.field() - role: RoleType = strawberry_django.field() + @strawberry.field + def role(self, id: int) -> RoleType: + return models.Role.objects.get(id=id) role_list: List[RoleType] = strawberry_django.field() - route_target: RouteTargetType = strawberry_django.field() + @strawberry.field + def route_target(self, id: int) -> RouteTargetType: + return models.RouteTarget.objects.get(id=id) route_target_list: List[RouteTargetType] = strawberry_django.field() - service: ServiceType = strawberry_django.field() + @strawberry.field + def service(self, id: int) -> ServiceType: + return models.Service.objects.get(id=id) service_list: List[ServiceType] = strawberry_django.field() - service_template: ServiceTemplateType = strawberry_django.field() + @strawberry.field + def service_template(self, id: int) -> ServiceTemplateType: + return models.ServiceTemplate.objects.get(id=id) service_template_list: List[ServiceTemplateType] = strawberry_django.field() - fhrp_group: FHRPGroupType = strawberry_django.field() + @strawberry.field + def fhrp_group(self, id: int) -> FHRPGroupType: + return models.FHRPGroup.objects.get(id=id) fhrp_group_list: List[FHRPGroupType] = strawberry_django.field() - fhrp_group_assignment: FHRPGroupAssignmentType = strawberry_django.field() + @strawberry.field + def fhrp_group_assignment(self, id: int) -> FHRPGroupAssignmentType: + return models.FHRPGroupAssignment.objects.get(id=id) fhrp_group_assignment_list: List[FHRPGroupAssignmentType] = strawberry_django.field() - vlan: VLANType = strawberry_django.field() + @strawberry.field + def vlan(self, id: int) -> VLANType: + return models.VLAN.objects.get(id=id) vlan_list: List[VLANType] = strawberry_django.field() - vlan_group: VLANGroupType = strawberry_django.field() + @strawberry.field + def vlan_group(self, id: int) -> VLANGroupType: + return models.VLANGroup.objects.get(id=id) vlan_group_list: List[VLANGroupType] = strawberry_django.field() - vrf: VRFType = strawberry_django.field() + @strawberry.field + def vrf(self, id: int) -> VRFType: + return models.VRF.objects.get(id=id) vrf_list: List[VRFType] = strawberry_django.field() diff --git a/netbox/tenancy/graphql/schema.py b/netbox/tenancy/graphql/schema.py index e82b3ad9c..c5dc63a7b 100644 --- a/netbox/tenancy/graphql/schema.py +++ b/netbox/tenancy/graphql/schema.py @@ -8,20 +8,32 @@ from .types import * @strawberry.type class TenancyQuery: - tenant: TenantType = strawberry_django.field() + @strawberry.field + def circutenantit(self, id: int) -> TenantType: + return models.Tenant.objects.get(id=id) tenant_list: List[TenantType] = strawberry_django.field() - tenant_group: TenantGroupType = strawberry_django.field() + @strawberry.field + def tenant_group(self, id: int) -> TenantGroupType: + return models.TenantGroup.objects.get(id=id) tenant_group_list: List[TenantGroupType] = strawberry_django.field() - contact: ContactType = strawberry_django.field() + @strawberry.field + def contact(self, id: int) -> ContactType: + return models.Contact.objects.get(id=id) contact_list: List[ContactType] = strawberry_django.field() - contact_role: ContactRoleType = strawberry_django.field() + @strawberry.field + def contact_role(self, id: int) -> ContactRoleType: + return models.ContactRole.objects.get(id=id) contact_role_list: List[ContactRoleType] = strawberry_django.field() - contact_group: ContactGroupType = strawberry_django.field() + @strawberry.field + def contact_group(self, id: int) -> ContactGroupType: + return models.ContactGroup.objects.get(id=id) contact_group_list: List[ContactGroupType] = strawberry_django.field() - contact_assignment: ContactAssignmentType = strawberry_django.field() + @strawberry.field + def contact_assignment(self, id: int) -> ContactAssignmentType: + return models.ContactAssignment.objects.get(id=id) contact_assignment_list: List[ContactAssignmentType] = strawberry_django.field() diff --git a/netbox/users/graphql/schema.py b/netbox/users/graphql/schema.py index 575bafecd..c9a8211d4 100644 --- a/netbox/users/graphql/schema.py +++ b/netbox/users/graphql/schema.py @@ -9,8 +9,12 @@ from .types import * @strawberry.type class UsersQuery: - group: GroupType = strawberry_django.field() + @strawberry.field + def group(self, id: int) -> GroupType: + return models.Group.objects.get(id=id) group_list: List[GroupType] = strawberry_django.field() - user: UserType = strawberry_django.field() + @strawberry.field + def user(self, id: int) -> UserType: + return models.User.objects.get(id=id) user_list: List[UserType] = strawberry_django.field() diff --git a/netbox/virtualization/graphql/schema.py b/netbox/virtualization/graphql/schema.py index d226e2fea..0d6e0b28b 100644 --- a/netbox/virtualization/graphql/schema.py +++ b/netbox/virtualization/graphql/schema.py @@ -8,20 +8,32 @@ from .types import * @strawberry.type class VirtualizationQuery: - cluster: ClusterType = strawberry_django.field() + @strawberry.field + def cluster(self, id: int) -> ClusterType: + return models.Cluster.objects.get(id=id) cluster_list: List[ClusterType] = strawberry_django.field() - cluster_group: ClusterGroupType = strawberry_django.field() + @strawberry.field + def cluster_group(self, id: int) -> ClusterGroupType: + return models.ClusterGroup.objects.get(id=id) cluster_group_list: List[ClusterGroupType] = strawberry_django.field() - cluster_type: ClusterTypeType = strawberry_django.field() + @strawberry.field + def cluster_type(self, id: int) -> ClusterTypeType: + return models.ClusterType.objects.get(id=id) cluster_type_list: List[ClusterTypeType] = strawberry_django.field() - virtual_machine: VirtualMachineType = strawberry_django.field() + @strawberry.field + def virtual_machine(self, id: int) -> VirtualMachineType: + return models.VirtualMachine.objects.get(id=id) virtual_machine_list: List[VirtualMachineType] = strawberry_django.field() - vm_interface: VMInterfaceType = strawberry_django.field() + @strawberry.field + def vm_interface(self, id: int) -> VMInterfaceType: + return models.VMInterface.objects.get(id=id) vm_interface_list: List[VMInterfaceType] = strawberry_django.field() - virtual_disk: VirtualDiskType = strawberry_django.field() + @strawberry.field + def virtual_disk(self, id: int) -> VirtualDiskType: + return models.VirtualDisk.objects.get(id=id) virtual_disk_list: List[VirtualDiskType] = strawberry_django.field() diff --git a/netbox/vpn/graphql/schema.py b/netbox/vpn/graphql/schema.py index 996e29af3..e10cbbbd5 100644 --- a/netbox/vpn/graphql/schema.py +++ b/netbox/vpn/graphql/schema.py @@ -8,32 +8,52 @@ from .types import * @strawberry.type class VPNQuery: - ike_policy: IKEPolicyType = strawberry_django.field() + @strawberry.field + def ike_policy(self, id: int) -> IKEPolicyType: + return models.IKEPolicy.objects.get(id=id) ike_policy_list: List[IKEPolicyType] = strawberry_django.field() - ike_proposal: IKEProposalType = strawberry_django.field() + @strawberry.field + def ike_proposal(self, id: int) -> IKEProposalType: + return models.IKEProposal.objects.get(id=id) ike_proposal_list: List[IKEProposalType] = strawberry_django.field() - ipsec_policy: IPSecPolicyType = strawberry_django.field() + @strawberry.field + def ipsec_policy(self, id: int) -> IPSecPolicyType: + return models.IPSecPolicy.objects.get(id=id) ipsec_policy_list: List[IPSecPolicyType] = strawberry_django.field() - ipsec_profile: IPSecProfileType = strawberry_django.field() + @strawberry.field + def ipsec_profile(self, id: int) -> IPSecProfileType: + return models.IPSecProfile.objects.get(id=id) ipsec_profile_list: List[IPSecProfileType] = strawberry_django.field() - ipsec_proposal: IPSecProposalType = strawberry_django.field() + @strawberry.field + def ipsec_proposal(self, id: int) -> IPSecProposalType: + return models.IPSecProposal.objects.get(id=id) ipsec_proposal_list: List[IPSecProposalType] = strawberry_django.field() - l2vpn: L2VPNType = strawberry_django.field() + @strawberry.field + def l2vpn(self, id: int) -> L2VPNType: + return models.L2VPN.objects.get(id=id) l2vpn_list: List[L2VPNType] = strawberry_django.field() - l2vpn_termination: L2VPNTerminationType = strawberry_django.field() + @strawberry.field + def l2vpn_termination(self, id: int) -> L2VPNTerminationType: + return models.L2VPNTermination.objects.get(id=id) l2vpn_termination_list: List[L2VPNTerminationType] = strawberry_django.field() - tunnel: TunnelType = strawberry_django.field() + @strawberry.field + def tunnel(self, id: int) -> TunnelType: + return models.Tunnel.objects.get(id=id) tunnel_list: List[TunnelType] = strawberry_django.field() - tunnel_group: TunnelGroupType = strawberry_django.field() + @strawberry.field + def tunnel_group(self, id: int) -> TunnelGroupType: + return models.TunnelGroup.objects.get(id=id) tunnel_group_list: List[TunnelGroupType] = strawberry_django.field() - tunnel_termination: TunnelTerminationType = strawberry_django.field() + @strawberry.field + def tunnel_termination(self, id: int) -> TunnelTerminationType: + return models.TunnelTermination.objects.get(id=id) tunnel_termination_list: List[TunnelTerminationType] = strawberry_django.field() diff --git a/netbox/wireless/graphql/schema.py b/netbox/wireless/graphql/schema.py index bd16cba3d..0447ad85c 100644 --- a/netbox/wireless/graphql/schema.py +++ b/netbox/wireless/graphql/schema.py @@ -8,11 +8,17 @@ from .types import * @strawberry.type class WirelessQuery: - wireless_lan: WirelessLANType = strawberry_django.field() + @strawberry.field + def wireless_lan(self, id: int) -> WirelessLANType: + return models.WirelessLAN.objects.get(id=id) wireless_lan_list: List[WirelessLANType] = strawberry_django.field() - wireless_lan_group: WirelessLANGroupType = strawberry_django.field() + @strawberry.field + def wireless_lan_group(self, id: int) -> WirelessLANGroupType: + return models.WirelessLANGroup.objects.get(id=id) wireless_lan_group_list: List[WirelessLANGroupType] = strawberry_django.field() - wireless_link: WirelessLinkType = strawberry_django.field() + @strawberry.field + def wireless_link(self, id: int) -> WirelessLinkType: + return models.WirelessLink.objects.get(id=id) wireless_link_list: List[WirelessLinkType] = strawberry_django.field()