Просмотр исходного кода

19724 pagingate graphql queries

Arthur 4 месяцев назад
Родитель
Сommit
0c4d0fa2e8

+ 14 - 13
netbox/circuits/graphql/schema.py

@@ -1,7 +1,6 @@
-from typing import List
-
 import strawberry
 import strawberry_django
+from strawberry_django.pagination import OffsetPaginated
 
 from .types import *
 
@@ -9,34 +8,36 @@ from .types import *
 @strawberry.type(name="Query")
 class CircuitsQuery:
     circuit: CircuitType = strawberry_django.field()
-    circuit_list: List[CircuitType] = strawberry_django.field()
+    circuit_list: OffsetPaginated[CircuitType] = strawberry_django.offset_paginated()
 
     circuit_termination: CircuitTerminationType = strawberry_django.field()
-    circuit_termination_list: List[CircuitTerminationType] = strawberry_django.field()
+    circuit_termination_list: OffsetPaginated[CircuitTerminationType] = strawberry_django.offset_paginated()
 
     circuit_type: CircuitTypeType = strawberry_django.field()
-    circuit_type_list: List[CircuitTypeType] = strawberry_django.field()
+    circuit_type_list: OffsetPaginated[CircuitTypeType] = strawberry_django.offset_paginated()
 
     circuit_group: CircuitGroupType = strawberry_django.field()
-    circuit_group_list: List[CircuitGroupType] = strawberry_django.field()
+    circuit_group_list: OffsetPaginated[CircuitGroupType] = strawberry_django.offset_paginated()
 
     circuit_group_assignment: CircuitGroupAssignmentType = strawberry_django.field()
-    circuit_group_assignment_list: List[CircuitGroupAssignmentType] = strawberry_django.field()
+    circuit_group_assignment_list: OffsetPaginated[CircuitGroupAssignmentType] = strawberry_django.offset_paginated()
 
     provider: ProviderType = strawberry_django.field()
-    provider_list: List[ProviderType] = strawberry_django.field()
+    provider_list: OffsetPaginated[ProviderType] = strawberry_django.offset_paginated()
 
     provider_account: ProviderAccountType = strawberry_django.field()
-    provider_account_list: List[ProviderAccountType] = strawberry_django.field()
+    provider_account_list: OffsetPaginated[ProviderAccountType] = strawberry_django.offset_paginated()
 
     provider_network: ProviderNetworkType = strawberry_django.field()
-    provider_network_list: List[ProviderNetworkType] = strawberry_django.field()
+    provider_network_list: OffsetPaginated[ProviderNetworkType] = strawberry_django.offset_paginated()
 
     virtual_circuit: VirtualCircuitType = strawberry_django.field()
-    virtual_circuit_list: List[VirtualCircuitType] = strawberry_django.field()
+    virtual_circuit_list: OffsetPaginated[VirtualCircuitType] = strawberry_django.offset_paginated()
 
     virtual_circuit_termination: VirtualCircuitTerminationType = strawberry_django.field()
-    virtual_circuit_termination_list: List[VirtualCircuitTerminationType] = strawberry_django.field()
+    virtual_circuit_termination_list: OffsetPaginated[VirtualCircuitTerminationType] = (
+        strawberry_django.offset_paginated()
+    )
 
     virtual_circuit_type: VirtualCircuitTypeType = strawberry_django.field()
-    virtual_circuit_type_list: List[VirtualCircuitTypeType] = strawberry_django.field()
+    virtual_circuit_type_list: OffsetPaginated[VirtualCircuitTypeType] = strawberry_django.offset_paginated()

+ 3 - 4
netbox/core/graphql/schema.py

@@ -1,7 +1,6 @@
-from typing import List
-
 import strawberry
 import strawberry_django
+from strawberry_django.pagination import OffsetPaginated
 
 from .types import *
 
@@ -9,7 +8,7 @@ from .types import *
 @strawberry.type(name="Query")
 class CoreQuery:
     data_file: DataFileType = strawberry_django.field()
-    data_file_list: List[DataFileType] = strawberry_django.field()
+    data_file_list: OffsetPaginated[DataFileType] = strawberry_django.offset_paginated()
 
     data_source: DataSourceType = strawberry_django.field()
-    data_source_list: List[DataSourceType] = strawberry_django.field()
+    data_source_list: OffsetPaginated[DataSourceType] = strawberry_django.offset_paginated()

+ 46 - 45
netbox/dcim/graphql/schema.py

@@ -1,7 +1,6 @@
-from typing import List
-
 import strawberry
 import strawberry_django
+from strawberry_django.pagination import OffsetPaginated
 
 from .types import *
 
@@ -9,130 +8,132 @@ from .types import *
 @strawberry.type(name="Query")
 class DCIMQuery:
     cable: CableType = strawberry_django.field()
-    cable_list: List[CableType] = strawberry_django.field()
+    cable_list: OffsetPaginated[CableType] = strawberry_django.offset_paginated()
 
     console_port: ConsolePortType = strawberry_django.field()
-    console_port_list: List[ConsolePortType] = strawberry_django.field()
+    console_port_list: OffsetPaginated[ConsolePortType] = strawberry_django.offset_paginated()
 
     console_port_template: ConsolePortTemplateType = strawberry_django.field()
-    console_port_template_list: List[ConsolePortTemplateType] = strawberry_django.field()
+    console_port_template_list: OffsetPaginated[ConsolePortTemplateType] = strawberry_django.offset_paginated()
 
     console_server_port: ConsoleServerPortType = strawberry_django.field()
-    console_server_port_list: List[ConsoleServerPortType] = strawberry_django.field()
+    console_server_port_list: OffsetPaginated[ConsoleServerPortType] = strawberry_django.offset_paginated()
 
     console_server_port_template: ConsoleServerPortTemplateType = strawberry_django.field()
-    console_server_port_template_list: List[ConsoleServerPortTemplateType] = strawberry_django.field()
+    console_server_port_template_list: OffsetPaginated[ConsoleServerPortTemplateType] = (
+        strawberry_django.offset_paginated()
+    )
 
     device: DeviceType = strawberry_django.field()
-    device_list: List[DeviceType] = strawberry_django.field()
+    device_list: OffsetPaginated[DeviceType] = strawberry_django.offset_paginated()
 
     device_bay: DeviceBayType = strawberry_django.field()
-    device_bay_list: List[DeviceBayType] = strawberry_django.field()
+    device_bay_list: OffsetPaginated[DeviceBayType] = strawberry_django.offset_paginated()
 
     device_bay_template: DeviceBayTemplateType = strawberry_django.field()
-    device_bay_template_list: List[DeviceBayTemplateType] = strawberry_django.field()
+    device_bay_template_list: OffsetPaginated[DeviceBayTemplateType] = strawberry_django.offset_paginated()
 
     device_role: DeviceRoleType = strawberry_django.field()
-    device_role_list: List[DeviceRoleType] = strawberry_django.field()
+    device_role_list: OffsetPaginated[DeviceRoleType] = strawberry_django.offset_paginated()
 
     device_type: DeviceTypeType = strawberry_django.field()
-    device_type_list: List[DeviceTypeType] = strawberry_django.field()
+    device_type_list: OffsetPaginated[DeviceTypeType] = strawberry_django.offset_paginated()
 
     front_port: FrontPortType = strawberry_django.field()
-    front_port_list: List[FrontPortType] = strawberry_django.field()
+    front_port_list: OffsetPaginated[FrontPortType] = strawberry_django.offset_paginated()
 
     front_port_template: FrontPortTemplateType = strawberry_django.field()
-    front_port_template_list: List[FrontPortTemplateType] = strawberry_django.field()
+    front_port_template_list: OffsetPaginated[FrontPortTemplateType] = strawberry_django.offset_paginated()
 
     mac_address: MACAddressType = strawberry_django.field()
-    mac_address_list: List[MACAddressType] = strawberry_django.field()
+    mac_address_list: OffsetPaginated[MACAddressType] = strawberry_django.offset_paginated()
 
     interface: InterfaceType = strawberry_django.field()
-    interface_list: List[InterfaceType] = strawberry_django.field()
+    interface_list: OffsetPaginated[InterfaceType] = strawberry_django.offset_paginated()
 
     interface_template: InterfaceTemplateType = strawberry_django.field()
-    interface_template_list: List[InterfaceTemplateType] = strawberry_django.field()
+    interface_template_list: OffsetPaginated[InterfaceTemplateType] = strawberry_django.offset_paginated()
 
     inventory_item: InventoryItemType = strawberry_django.field()
-    inventory_item_list: List[InventoryItemType] = strawberry_django.field()
+    inventory_item_list: OffsetPaginated[InventoryItemType] = strawberry_django.offset_paginated()
 
     inventory_item_role: InventoryItemRoleType = strawberry_django.field()
-    inventory_item_role_list: List[InventoryItemRoleType] = strawberry_django.field()
+    inventory_item_role_list: OffsetPaginated[InventoryItemRoleType] = strawberry_django.offset_paginated()
 
     inventory_item_template: InventoryItemTemplateType = strawberry_django.field()
-    inventory_item_template_list: List[InventoryItemTemplateType] = strawberry_django.field()
+    inventory_item_template_list: OffsetPaginated[InventoryItemTemplateType] = strawberry_django.offset_paginated()
 
     location: LocationType = strawberry_django.field()
-    location_list: List[LocationType] = strawberry_django.field()
+    location_list: OffsetPaginated[LocationType] = strawberry_django.offset_paginated()
 
     manufacturer: ManufacturerType = strawberry_django.field()
-    manufacturer_list: List[ManufacturerType] = strawberry_django.field()
+    manufacturer_list: OffsetPaginated[ManufacturerType] = strawberry_django.offset_paginated()
 
     module: ModuleType = strawberry_django.field()
-    module_list: List[ModuleType] = strawberry_django.field()
+    module_list: OffsetPaginated[ModuleType] = strawberry_django.offset_paginated()
 
     module_bay: ModuleBayType = strawberry_django.field()
-    module_bay_list: List[ModuleBayType] = strawberry_django.field()
+    module_bay_list: OffsetPaginated[ModuleBayType] = strawberry_django.offset_paginated()
 
     module_bay_template: ModuleBayTemplateType = strawberry_django.field()
-    module_bay_template_list: List[ModuleBayTemplateType] = strawberry_django.field()
+    module_bay_template_list: OffsetPaginated[ModuleBayTemplateType] = strawberry_django.offset_paginated()
 
     module_type_profile: ModuleTypeProfileType = strawberry_django.field()
-    module_type_profile_list: List[ModuleTypeProfileType] = strawberry_django.field()
+    module_type_profile_list: OffsetPaginated[ModuleTypeProfileType] = strawberry_django.offset_paginated()
 
     module_type: ModuleTypeType = strawberry_django.field()
-    module_type_list: List[ModuleTypeType] = strawberry_django.field()
+    module_type_list: OffsetPaginated[ModuleTypeType] = strawberry_django.offset_paginated()
 
     platform: PlatformType = strawberry_django.field()
-    platform_list: List[PlatformType] = strawberry_django.field()
+    platform_list: OffsetPaginated[PlatformType] = strawberry_django.offset_paginated()
 
     power_feed: PowerFeedType = strawberry_django.field()
-    power_feed_list: List[PowerFeedType] = strawberry_django.field()
+    power_feed_list: OffsetPaginated[PowerFeedType] = strawberry_django.offset_paginated()
 
     power_outlet: PowerOutletType = strawberry_django.field()
-    power_outlet_list: List[PowerOutletType] = strawberry_django.field()
+    power_outlet_list: OffsetPaginated[PowerOutletType] = strawberry_django.offset_paginated()
 
     power_outlet_template: PowerOutletTemplateType = strawberry_django.field()
-    power_outlet_template_list: List[PowerOutletTemplateType] = strawberry_django.field()
+    power_outlet_template_list: OffsetPaginated[PowerOutletTemplateType] = strawberry_django.offset_paginated()
 
     power_panel: PowerPanelType = strawberry_django.field()
-    power_panel_list: List[PowerPanelType] = strawberry_django.field()
+    power_panel_list: OffsetPaginated[PowerPanelType] = strawberry_django.offset_paginated()
 
     power_port: PowerPortType = strawberry_django.field()
-    power_port_list: List[PowerPortType] = strawberry_django.field()
+    power_port_list: OffsetPaginated[PowerPortType] = strawberry_django.offset_paginated()
 
     power_port_template: PowerPortTemplateType = strawberry_django.field()
-    power_port_template_list: List[PowerPortTemplateType] = strawberry_django.field()
+    power_port_template_list: OffsetPaginated[PowerPortTemplateType] = strawberry_django.offset_paginated()
 
     rack_type: RackTypeType = strawberry_django.field()
-    rack_type_list: List[RackTypeType] = strawberry_django.field()
+    rack_type_list: OffsetPaginated[RackTypeType] = strawberry_django.offset_paginated()
 
     rack: RackType = strawberry_django.field()
-    rack_list: List[RackType] = strawberry_django.field()
+    rack_list: OffsetPaginated[RackType] = strawberry_django.offset_paginated()
 
     rack_reservation: RackReservationType = strawberry_django.field()
-    rack_reservation_list: List[RackReservationType] = strawberry_django.field()
+    rack_reservation_list: OffsetPaginated[RackReservationType] = strawberry_django.offset_paginated()
 
     rack_role: RackRoleType = strawberry_django.field()
-    rack_role_list: List[RackRoleType] = strawberry_django.field()
+    rack_role_list: OffsetPaginated[RackRoleType] = strawberry_django.offset_paginated()
 
     rear_port: RearPortType = strawberry_django.field()
-    rear_port_list: List[RearPortType] = strawberry_django.field()
+    rear_port_list: OffsetPaginated[RearPortType] = strawberry_django.offset_paginated()
 
     rear_port_template: RearPortTemplateType = strawberry_django.field()
-    rear_port_template_list: List[RearPortTemplateType] = strawberry_django.field()
+    rear_port_template_list: OffsetPaginated[RearPortTemplateType] = strawberry_django.offset_paginated()
 
     region: RegionType = strawberry_django.field()
-    region_list: List[RegionType] = strawberry_django.field()
+    region_list: OffsetPaginated[RegionType] = strawberry_django.offset_paginated()
 
     site: SiteType = strawberry_django.field()
-    site_list: List[SiteType] = strawberry_django.field()
+    site_list: OffsetPaginated[SiteType] = strawberry_django.offset_paginated()
 
     site_group: SiteGroupType = strawberry_django.field()
-    site_group_list: List[SiteGroupType] = strawberry_django.field()
+    site_group_list: OffsetPaginated[SiteGroupType] = strawberry_django.offset_paginated()
 
     virtual_chassis: VirtualChassisType = strawberry_django.field()
-    virtual_chassis_list: List[VirtualChassisType] = strawberry_django.field()
+    virtual_chassis_list: OffsetPaginated[VirtualChassisType] = strawberry_django.offset_paginated()
 
     virtual_device_context: VirtualDeviceContextType = strawberry_django.field()
-    virtual_device_context_list: List[VirtualDeviceContextType] = strawberry_django.field()
+    virtual_device_context_list: OffsetPaginated[VirtualDeviceContextType] = strawberry_django.offset_paginated()

+ 18 - 19
netbox/extras/graphql/schema.py

@@ -1,7 +1,6 @@
-from typing import List
-
 import strawberry
 import strawberry_django
+from strawberry_django.pagination import OffsetPaginated
 
 from .types import *
 
@@ -9,52 +8,52 @@ from .types import *
 @strawberry.type(name="Query")
 class ExtrasQuery:
     config_context: ConfigContextType = strawberry_django.field()
-    config_context_list: List[ConfigContextType] = strawberry_django.field()
+    config_context_list: OffsetPaginated[ConfigContextType] = strawberry_django.offset_paginated()
 
     config_context_profile: ConfigContextProfileType = strawberry_django.field()
-    config_context_profile_list: List[ConfigContextProfileType] = strawberry_django.field()
+    config_context_profile_list: OffsetPaginated[ConfigContextProfileType] = strawberry_django.offset_paginated()
 
     config_template: ConfigTemplateType = strawberry_django.field()
-    config_template_list: List[ConfigTemplateType] = strawberry_django.field()
+    config_template_list: OffsetPaginated[ConfigTemplateType] = strawberry_django.offset_paginated()
 
     custom_field: CustomFieldType = strawberry_django.field()
-    custom_field_list: List[CustomFieldType] = strawberry_django.field()
+    custom_field_list: OffsetPaginated[CustomFieldType] = strawberry_django.offset_paginated()
 
     custom_field_choice_set: CustomFieldChoiceSetType = strawberry_django.field()
-    custom_field_choice_set_list: List[CustomFieldChoiceSetType] = strawberry_django.field()
+    custom_field_choice_set_list: OffsetPaginated[CustomFieldChoiceSetType] = strawberry_django.offset_paginated()
 
     custom_link: CustomLinkType = strawberry_django.field()
-    custom_link_list: List[CustomLinkType] = strawberry_django.field()
+    custom_link_list: OffsetPaginated[CustomLinkType] = strawberry_django.offset_paginated()
 
     export_template: ExportTemplateType = strawberry_django.field()
-    export_template_list: List[ExportTemplateType] = strawberry_django.field()
+    export_template_list: OffsetPaginated[ExportTemplateType] = strawberry_django.offset_paginated()
 
     image_attachment: ImageAttachmentType = strawberry_django.field()
-    image_attachment_list: List[ImageAttachmentType] = strawberry_django.field()
+    image_attachment_list: OffsetPaginated[ImageAttachmentType] = strawberry_django.offset_paginated()
 
     saved_filter: SavedFilterType = strawberry_django.field()
-    saved_filter_list: List[SavedFilterType] = strawberry_django.field()
+    saved_filter_list: OffsetPaginated[SavedFilterType] = strawberry_django.offset_paginated()
 
     table_config: TableConfigType = strawberry_django.field()
-    table_config_list: List[TableConfigType] = strawberry_django.field()
+    table_config_list: OffsetPaginated[TableConfigType] = strawberry_django.offset_paginated()
 
     journal_entry: JournalEntryType = strawberry_django.field()
-    journal_entry_list: List[JournalEntryType] = strawberry_django.field()
+    journal_entry_list: OffsetPaginated[JournalEntryType] = strawberry_django.offset_paginated()
 
     notification: NotificationType = strawberry_django.field()
-    notification_list: List[NotificationType] = strawberry_django.field()
+    notification_list: OffsetPaginated[NotificationType] = strawberry_django.offset_paginated()
 
     notification_group: NotificationGroupType = strawberry_django.field()
-    notification_group_list: List[NotificationGroupType] = strawberry_django.field()
+    notification_group_list: OffsetPaginated[NotificationGroupType] = strawberry_django.offset_paginated()
 
     subscription: SubscriptionType = strawberry_django.field()
-    subscription_list: List[SubscriptionType] = strawberry_django.field()
+    subscription_list: OffsetPaginated[SubscriptionType] = strawberry_django.offset_paginated()
 
     tag: TagType = strawberry_django.field()
-    tag_list: List[TagType] = strawberry_django.field()
+    tag_list: OffsetPaginated[TagType] = strawberry_django.offset_paginated()
 
     webhook: WebhookType = strawberry_django.field()
-    webhook_list: List[WebhookType] = strawberry_django.field()
+    webhook_list: OffsetPaginated[WebhookType] = strawberry_django.offset_paginated()
 
     event_rule: EventRuleType = strawberry_django.field()
-    event_rule_list: List[EventRuleType] = strawberry_django.field()
+    event_rule_list: OffsetPaginated[EventRuleType] = strawberry_django.offset_paginated()

+ 19 - 20
netbox/ipam/graphql/schema.py

@@ -1,7 +1,6 @@
-from typing import List
-
 import strawberry
 import strawberry_django
+from strawberry_django.pagination import OffsetPaginated
 
 from .types import *
 
@@ -9,55 +8,55 @@ from .types import *
 @strawberry.type(name="Query")
 class IPAMQuery:
     asn: ASNType = strawberry_django.field()
-    asn_list: List[ASNType] = strawberry_django.field()
+    asn_list: OffsetPaginated[ASNType] = strawberry_django.offset_paginated()
 
     asn_range: ASNRangeType = strawberry_django.field()
-    asn_range_list: List[ASNRangeType] = strawberry_django.field()
+    asn_range_list: OffsetPaginated[ASNRangeType] = strawberry_django.offset_paginated()
 
     aggregate: AggregateType = strawberry_django.field()
-    aggregate_list: List[AggregateType] = strawberry_django.field()
+    aggregate_list: OffsetPaginated[AggregateType] = strawberry_django.offset_paginated()
 
     ip_address: IPAddressType = strawberry_django.field()
-    ip_address_list: List[IPAddressType] = strawberry_django.field()
+    ip_address_list: OffsetPaginated[IPAddressType] = strawberry_django.offset_paginated()
 
     ip_range: IPRangeType = strawberry_django.field()
-    ip_range_list: List[IPRangeType] = strawberry_django.field()
+    ip_range_list: OffsetPaginated[IPRangeType] = strawberry_django.offset_paginated()
 
     prefix: PrefixType = strawberry_django.field()
-    prefix_list: List[PrefixType] = strawberry_django.field()
+    prefix_list: OffsetPaginated[PrefixType] = strawberry_django.offset_paginated()
 
     rir: RIRType = strawberry_django.field()
-    rir_list: List[RIRType] = strawberry_django.field()
+    rir_list: OffsetPaginated[RIRType] = strawberry_django.offset_paginated()
 
     role: RoleType = strawberry_django.field()
-    role_list: List[RoleType] = strawberry_django.field()
+    role_list: OffsetPaginated[RoleType] = strawberry_django.offset_paginated()
 
     route_target: RouteTargetType = strawberry_django.field()
-    route_target_list: List[RouteTargetType] = strawberry_django.field()
+    route_target_list: OffsetPaginated[RouteTargetType] = strawberry_django.offset_paginated()
 
     service: ServiceType = strawberry_django.field()
-    service_list: List[ServiceType] = strawberry_django.field()
+    service_list: OffsetPaginated[ServiceType] = strawberry_django.offset_paginated()
 
     service_template: ServiceTemplateType = strawberry_django.field()
-    service_template_list: List[ServiceTemplateType] = strawberry_django.field()
+    service_template_list: OffsetPaginated[ServiceTemplateType] = strawberry_django.offset_paginated()
 
     fhrp_group: FHRPGroupType = strawberry_django.field()
-    fhrp_group_list: List[FHRPGroupType] = strawberry_django.field()
+    fhrp_group_list: OffsetPaginated[FHRPGroupType] = strawberry_django.offset_paginated()
 
     fhrp_group_assignment: FHRPGroupAssignmentType = strawberry_django.field()
-    fhrp_group_assignment_list: List[FHRPGroupAssignmentType] = strawberry_django.field()
+    fhrp_group_assignment_list: OffsetPaginated[FHRPGroupAssignmentType] = strawberry_django.offset_paginated()
 
     vlan: VLANType = strawberry_django.field()
-    vlan_list: List[VLANType] = strawberry_django.field()
+    vlan_list: OffsetPaginated[VLANType] = strawberry_django.offset_paginated()
 
     vlan_group: VLANGroupType = strawberry_django.field()
-    vlan_group_list: List[VLANGroupType] = strawberry_django.field()
+    vlan_group_list: OffsetPaginated[VLANGroupType] = strawberry_django.offset_paginated()
 
     vlan_translation_policy: VLANTranslationPolicyType = strawberry_django.field()
-    vlan_translation_policy_list: List[VLANTranslationPolicyType] = strawberry_django.field()
+    vlan_translation_policy_list: OffsetPaginated[VLANTranslationPolicyType] = strawberry_django.offset_paginated()
 
     vlan_translation_rule: VLANTranslationRuleType = strawberry_django.field()
-    vlan_translation_rule_list: List[VLANTranslationRuleType] = strawberry_django.field()
+    vlan_translation_rule_list: OffsetPaginated[VLANTranslationRuleType] = strawberry_django.offset_paginated()
 
     vrf: VRFType = strawberry_django.field()
-    vrf_list: List[VRFType] = strawberry_django.field()
+    vrf_list: OffsetPaginated[VRFType] = strawberry_django.offset_paginated()

+ 13 - 7
netbox/netbox/tests/test_graphql.py

@@ -88,13 +88,14 @@ class GraphQLAPITestCase(APITestCase):
         url = reverse('graphql')
 
         # A valid request should return the filtered list
-        query = '{location_list(filters: {site_id: "' + str(sites[0].pk) + '"}) {id site {id}}}'
+        query = '{location_list(filters: {site_id: "' + str(sites[0].pk) + '"}) {results {id site {id}} total_count}}'
         response = self.client.post(url, data={'query': query}, format="json", **self.header)
         self.assertHttpStatus(response, status.HTTP_200_OK)
         data = json.loads(response.content)
         self.assertNotIn('errors', data)
-        self.assertEqual(len(data['data']['location_list']), 1)
-        self.assertIsNotNone(data['data']['location_list'][0]['site'])
+        self.assertEqual(len(data['data']['location_list']['results']), 1)
+        self.assertEqual(data['data']['location_list']['total_count'], 1)
+        self.assertIsNotNone(data['data']['location_list']['results'][0]['site'])
 
         # Test OR logic
         query = """{
@@ -102,21 +103,26 @@ class GraphQLAPITestCase(APITestCase):
                 status: STATUS_PLANNED,
                 OR: {status: STATUS_STAGING}
             }) {
-                id site {id}
+                results {
+                    id site {id}
+                }
+                total_count
             }
         }"""
         response = self.client.post(url, data={'query': query}, format="json", **self.header)
         self.assertHttpStatus(response, status.HTTP_200_OK)
         data = json.loads(response.content)
         self.assertNotIn('errors', data)
-        self.assertEqual(len(data['data']['location_list']), 2)
+        self.assertEqual(len(data['data']['location_list']['results']), 2)
+        self.assertEqual(data['data']['location_list']['total_count'], 2)
 
         # An invalid request should return an empty list
-        query = '{location_list(filters: {site_id: "99999"}) {id site {id}}}'  # Invalid site ID
+        query = '{location_list(filters: {site_id: "99999"}) {results {id site {id}} total_count}}'  # Invalid site ID
         response = self.client.post(url, data={'query': query}, format="json", **self.header)
         self.assertHttpStatus(response, status.HTTP_200_OK)
         data = json.loads(response.content)
-        self.assertEqual(len(data['data']['location_list']), 0)
+        self.assertEqual(len(data['data']['location_list']['results']), 0)
+        self.assertEqual(data['data']['location_list']['total_count'], 0)
 
         # Removing the permissions from location should result in an empty locations list
         obj_perm.object_types.remove(ObjectType.objects.get_for_model(Location))

+ 7 - 8
netbox/tenancy/graphql/schema.py

@@ -1,7 +1,6 @@
-from typing import List
-
 import strawberry
 import strawberry_django
+from strawberry_django.pagination import OffsetPaginated
 
 from .types import *
 
@@ -9,19 +8,19 @@ from .types import *
 @strawberry.type(name="Query")
 class TenancyQuery:
     tenant: TenantType = strawberry_django.field()
-    tenant_list: List[TenantType] = strawberry_django.field()
+    tenant_list: OffsetPaginated[TenantType] = strawberry_django.offset_paginated()
 
     tenant_group: TenantGroupType = strawberry_django.field()
-    tenant_group_list: List[TenantGroupType] = strawberry_django.field()
+    tenant_group_list: OffsetPaginated[TenantGroupType] = strawberry_django.offset_paginated()
 
     contact: ContactType = strawberry_django.field()
-    contact_list: List[ContactType] = strawberry_django.field()
+    contact_list: OffsetPaginated[ContactType] = strawberry_django.offset_paginated()
 
     contact_role: ContactRoleType = strawberry_django.field()
-    contact_role_list: List[ContactRoleType] = strawberry_django.field()
+    contact_role_list: OffsetPaginated[ContactRoleType] = strawberry_django.offset_paginated()
 
     contact_group: ContactGroupType = strawberry_django.field()
-    contact_group_list: List[ContactGroupType] = strawberry_django.field()
+    contact_group_list: OffsetPaginated[ContactGroupType] = strawberry_django.offset_paginated()
 
     contact_assignment: ContactAssignmentType = strawberry_django.field()
-    contact_assignment_list: List[ContactAssignmentType] = strawberry_django.field()
+    contact_assignment_list: OffsetPaginated[ContactAssignmentType] = strawberry_django.offset_paginated()

+ 3 - 4
netbox/users/graphql/schema.py

@@ -1,7 +1,6 @@
-from typing import List
-
 import strawberry
 import strawberry_django
+from strawberry_django.pagination import OffsetPaginated
 
 from .types import *
 
@@ -9,7 +8,7 @@ from .types import *
 @strawberry.type(name="Query")
 class UsersQuery:
     group: GroupType = strawberry_django.field()
-    group_list: List[GroupType] = strawberry_django.field()
+    group_list: OffsetPaginated[GroupType] = strawberry_django.offset_paginated()
 
     user: UserType = strawberry_django.field()
-    user_list: List[UserType] = strawberry_django.field()
+    user_list: OffsetPaginated[UserType] = strawberry_django.offset_paginated()

+ 7 - 8
netbox/virtualization/graphql/schema.py

@@ -1,7 +1,6 @@
-from typing import List
-
 import strawberry
 import strawberry_django
+from strawberry_django.pagination import OffsetPaginated
 
 from .types import *
 
@@ -9,19 +8,19 @@ from .types import *
 @strawberry.type(name="Query")
 class VirtualizationQuery:
     cluster: ClusterType = strawberry_django.field()
-    cluster_list: List[ClusterType] = strawberry_django.field()
+    cluster_list: OffsetPaginated[ClusterType] = strawberry_django.offset_paginated()
 
     cluster_group: ClusterGroupType = strawberry_django.field()
-    cluster_group_list: List[ClusterGroupType] = strawberry_django.field()
+    cluster_group_list: OffsetPaginated[ClusterGroupType] = strawberry_django.offset_paginated()
 
     cluster_type: ClusterTypeType = strawberry_django.field()
-    cluster_type_list: List[ClusterTypeType] = strawberry_django.field()
+    cluster_type_list: OffsetPaginated[ClusterTypeType] = strawberry_django.offset_paginated()
 
     virtual_machine: VirtualMachineType = strawberry_django.field()
-    virtual_machine_list: List[VirtualMachineType] = strawberry_django.field()
+    virtual_machine_list: OffsetPaginated[VirtualMachineType] = strawberry_django.offset_paginated()
 
     vm_interface: VMInterfaceType = strawberry_django.field()
-    vm_interface_list: List[VMInterfaceType] = strawberry_django.field()
+    vm_interface_list: OffsetPaginated[VMInterfaceType] = strawberry_django.offset_paginated()
 
     virtual_disk: VirtualDiskType = strawberry_django.field()
-    virtual_disk_list: List[VirtualDiskType] = strawberry_django.field()
+    virtual_disk_list: OffsetPaginated[VirtualDiskType] = strawberry_django.offset_paginated()

+ 11 - 12
netbox/vpn/graphql/schema.py

@@ -1,7 +1,6 @@
-from typing import List
-
 import strawberry
 import strawberry_django
+from strawberry_django.pagination import OffsetPaginated
 
 from .types import *
 
@@ -9,31 +8,31 @@ from .types import *
 @strawberry.type(name="Query")
 class VPNQuery:
     ike_policy: IKEPolicyType = strawberry_django.field()
-    ike_policy_list: List[IKEPolicyType] = strawberry_django.field()
+    ike_policy_list: OffsetPaginated[IKEPolicyType] = strawberry_django.offset_paginated()
 
     ike_proposal: IKEProposalType = strawberry_django.field()
-    ike_proposal_list: List[IKEProposalType] = strawberry_django.field()
+    ike_proposal_list: OffsetPaginated[IKEProposalType] = strawberry_django.offset_paginated()
 
     ipsec_policy: IPSecPolicyType = strawberry_django.field()
-    ipsec_policy_list: List[IPSecPolicyType] = strawberry_django.field()
+    ipsec_policy_list: OffsetPaginated[IPSecPolicyType] = strawberry_django.offset_paginated()
 
     ipsec_profile: IPSecProfileType = strawberry_django.field()
-    ipsec_profile_list: List[IPSecProfileType] = strawberry_django.field()
+    ipsec_profile_list: OffsetPaginated[IPSecProfileType] = strawberry_django.offset_paginated()
 
     ipsec_proposal: IPSecProposalType = strawberry_django.field()
-    ipsec_proposal_list: List[IPSecProposalType] = strawberry_django.field()
+    ipsec_proposal_list: OffsetPaginated[IPSecProposalType] = strawberry_django.offset_paginated()
 
     l2vpn: L2VPNType = strawberry_django.field()
-    l2vpn_list: List[L2VPNType] = strawberry_django.field()
+    l2vpn_list: OffsetPaginated[L2VPNType] = strawberry_django.offset_paginated()
 
     l2vpn_termination: L2VPNTerminationType = strawberry_django.field()
-    l2vpn_termination_list: List[L2VPNTerminationType] = strawberry_django.field()
+    l2vpn_termination_list: OffsetPaginated[L2VPNTerminationType] = strawberry_django.offset_paginated()
 
     tunnel: TunnelType = strawberry_django.field()
-    tunnel_list: List[TunnelType] = strawberry_django.field()
+    tunnel_list: OffsetPaginated[TunnelType] = strawberry_django.offset_paginated()
 
     tunnel_group: TunnelGroupType = strawberry_django.field()
-    tunnel_group_list: List[TunnelGroupType] = strawberry_django.field()
+    tunnel_group_list: OffsetPaginated[TunnelGroupType] = strawberry_django.offset_paginated()
 
     tunnel_termination: TunnelTerminationType = strawberry_django.field()
-    tunnel_termination_list: List[TunnelTerminationType] = strawberry_django.field()
+    tunnel_termination_list: OffsetPaginated[TunnelTerminationType] = strawberry_django.offset_paginated()

+ 4 - 5
netbox/wireless/graphql/schema.py

@@ -1,7 +1,6 @@
-from typing import List
-
 import strawberry
 import strawberry_django
+from strawberry_django.pagination import OffsetPaginated
 
 from .types import *
 
@@ -9,10 +8,10 @@ from .types import *
 @strawberry.type(name="Query")
 class WirelessQuery:
     wireless_lan: WirelessLANType = strawberry_django.field()
-    wireless_lan_list: List[WirelessLANType] = strawberry_django.field()
+    wireless_lan_list: OffsetPaginated[WirelessLANType] = strawberry_django.offset_paginated()
 
     wireless_lan_group: WirelessLANGroupType = strawberry_django.field()
-    wireless_lan_group_list: List[WirelessLANGroupType] = strawberry_django.field()
+    wireless_lan_group_list: OffsetPaginated[WirelessLANGroupType] = strawberry_django.offset_paginated()
 
     wireless_link: WirelessLinkType = strawberry_django.field()
-    wireless_link_list: List[WirelessLinkType] = strawberry_django.field()
+    wireless_link_list: OffsetPaginated[WirelessLinkType] = strawberry_django.offset_paginated()