diff --git a/app/graphql/types/world_index_type.rb b/app/graphql/types/world_index_type.rb index c413cb04e..5e48ab573 100644 --- a/app/graphql/types/world_index_type.rb +++ b/app/graphql/types/world_index_type.rb @@ -14,16 +14,12 @@ class WorldLocation < Types::BaseObject field :updated_at, GraphQL::Types::ISO8601DateTime, null: false end - field :body, String - field :international_delegations, [WorldLocation], null: false - field :world_locations, [WorldLocation], null: false - - def international_delegations - object.details[:international_delegations] + class WorldIndexDetails < BaseObject + field :body, String + field :international_delegations, [WorldLocation], null: false + field :world_locations, [WorldLocation], null: false end - def world_locations - object.details[:world_locations] - end + field :details, WorldIndexDetails end end diff --git a/spec/integration/graphql/world_index_spec.rb b/spec/integration/graphql/world_index_spec.rb index 714fecf02..229ce33ff 100644 --- a/spec/integration/graphql/world_index_spec.rb +++ b/spec/integration/graphql/world_index_spec.rb @@ -51,12 +51,14 @@ ... on WorldIndex { title - worldLocations { - ...worldLocationInfo - } + details { + worldLocations { + ...worldLocationInfo + } - internationalDelegations { - ...worldLocationInfo + internationalDelegations { + ...worldLocationInfo + } } } } @@ -67,26 +69,28 @@ data: { edition: { title: "Help and services around the world", - worldLocations: [ - { - active: true, - analyticsIdentifier: "WL1", - contentId: "d3b7ba48-5027-4a98-a594-1108d205dc66", - name: "Test World Location", - slug: "test-world-location", - updatedAt: "2024-10-18T14:22:38+01:00", - }, - ], - internationalDelegations: [ - { - active: false, - analyticsIdentifier: "WL2", - contentId: "f0313f16-e25c-4bfe-a0fc-e561833f705f", - name: "Test International Delegation", - slug: "test-international-delegation", - updatedAt: "2024-10-19T15:07:44+01:00", - }, - ], + details: { + worldLocations: [ + { + active: true, + analyticsIdentifier: "WL1", + contentId: "d3b7ba48-5027-4a98-a594-1108d205dc66", + name: "Test World Location", + slug: "test-world-location", + updatedAt: "2024-10-18T14:22:38+01:00", + }, + ], + internationalDelegations: [ + { + active: false, + analyticsIdentifier: "WL2", + contentId: "f0313f16-e25c-4bfe-a0fc-e561833f705f", + name: "Test International Delegation", + slug: "test-international-delegation", + updatedAt: "2024-10-19T15:07:44+01:00", + }, + ], + }, }, }, }