From 166ddca0e056b2cd97725230dcc1d5d063eb92cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matilda=20Landstr=C3=B6m?= Date: Wed, 2 Oct 2024 18:35:27 +0200 Subject: [PATCH] fix(SW-194): add accordion graphql request --- .../Fragments/Blocks/Accordion.graphql | 122 ++++++++++++++++++ .../Query/ContentPage/ContentPage.graphql | 13 ++ lib/graphql/_request.ts | 1 + types/enums/contentPage.ts | 1 + 4 files changed, 137 insertions(+) create mode 100644 lib/graphql/Fragments/Blocks/Accordion.graphql diff --git a/lib/graphql/Fragments/Blocks/Accordion.graphql b/lib/graphql/Fragments/Blocks/Accordion.graphql new file mode 100644 index 000000000..6f4ecb0c4 --- /dev/null +++ b/lib/graphql/Fragments/Blocks/Accordion.graphql @@ -0,0 +1,122 @@ +#import "../PageLink/AccountPageLink.graphql" +#import "../PageLink/ContentPageLink.graphql" +#import "../PageLink/HotelPageLink.graphql" +#import "../PageLink/LoyaltyPageLink.graphql" + +#import "../AccountPage/Ref.graphql" +#import "../ContentPage/Ref.graphql" +#import "../HotelPage/Ref.graphql" +#import "../LoyaltyPage/Ref.graphql" + +fragment Accordion_ContentPage on ContentPageBlocksAccordion { + __typename + accordion { + title + faq { + __typename + ...GlobalFaq + ...SpecificFaq + } + } +} + +fragment GlobalFaq on ContentPageBlocksAccordionBlockFaqGlobalFaq { + __typename + global_faq { + global_faqConnection { + edges { + node { + ... on Accordion { + __typename + title + questions { + question + answer { + json + embedded_itemsConnection { + edges { + node { + __typename + ...ContentPageLink + } + } + } + } + } + } + } + } + } + } +} + +fragment SpecificFaq on ContentPageBlocksAccordionBlockFaqSpecificFaq { + __typename + specific_faq { + questions { + question + answer { + json + embedded_itemsConnection { + edges { + node { + __typename + ...ContentPageLink + } + } + } + } + } + } +} + +fragment Accordion_ContentPageRefs on ContentPageBlocksAccordion { + accordion { + faq { + ...GlobalFaqRefs + ...SpecificFaqRefs + } + } +} + +fragment GlobalFaqRefs on ContentPageBlocksAccordionBlockFaqGlobalFaq { + global_faq { + global_faqConnection { + edges { + node { + ... on Accordion { + questions { + answer { + embedded_itemsConnection { + edges { + node { + __typename + ...ContentPageRef + } + } + } + } + } + } + } + } + } + } +} + +fragment SpecificFaqRefs on ContentPageBlocksAccordionBlockFaqSpecificFaq { + specific_faq { + questions { + answer { + embedded_itemsConnection { + edges { + node { + __typename + ...ContentPageRef + } + } + } + } + } + } +} diff --git a/lib/graphql/Query/ContentPage/ContentPage.graphql b/lib/graphql/Query/ContentPage/ContentPage.graphql index 686ed9329..f73dee9b9 100644 --- a/lib/graphql/Query/ContentPage/ContentPage.graphql +++ b/lib/graphql/Query/ContentPage/ContentPage.graphql @@ -1,5 +1,6 @@ #import "../../Fragments/System.graphql" +#import "../../Fragments/Blocks/Accordion.graphql" #import "../../Fragments/Blocks/CardsGrid.graphql" #import "../../Fragments/Blocks/Content.graphql" #import "../../Fragments/Blocks/DynamicContent.graphql" @@ -23,6 +24,17 @@ query GetContentPage($locale: String!, $uid: String!) { preamble ...NavigationLinks } + blocks { + __typename + ...CardsGrid_ContentPage + ...Content_ContentPage + ...DynamicContent_ContentPage + ...Shortcuts_ContentPage + ...Table_ContentPage + ...TextCols_ContentPage + ...UspGrid_ContentPage + ...Accordion_ContentPage + } sidebar { __typename ...ContentSidebar_ContentPage @@ -70,6 +82,7 @@ query GetContentPageRefs($locale: String!, $uid: String!) { } blocks { __typename + ...Accordion_ContentPageRefs ...CardsGrid_ContentPageRefs ...Content_ContentPageRefs ...DynamicContent_ContentPageRefs diff --git a/lib/graphql/_request.ts b/lib/graphql/_request.ts index 96246e453..4040dfd9e 100644 --- a/lib/graphql/_request.ts +++ b/lib/graphql/_request.ts @@ -130,6 +130,7 @@ export async function request( * version for one language, it throws an error which we have to recover * from here since it isn't an error. */ + return { data: error.response.data as T } } } diff --git a/types/enums/contentPage.ts b/types/enums/contentPage.ts index df5dab28e..16366a756 100644 --- a/types/enums/contentPage.ts +++ b/types/enums/contentPage.ts @@ -1,6 +1,7 @@ export namespace ContentPageEnum { export namespace ContentStack { export const enum blocks { + Accordion = "ContentPageBlocksAccordion", CardsGrid = "ContentPageBlocksCardsGrid", Content = "ContentPageBlocksContent", DynamicContent = "ContentPageBlocksDynamicContent",