Merged in feat/SW-1442-destination-overview-page (pull request #1188)
feat(SW-1442): added destination overview page * feat(SW-1442): added destination overview page Approved-by: Fredrik Thorsson Approved-by: Matilda Landström
This commit is contained in:
@@ -29,6 +29,13 @@ query GetContentPageSettings($uid: String!, $locale: String!) {
|
||||
}
|
||||
}
|
||||
}
|
||||
query GetDestinationOverviewPageSettings($uid: String!, $locale: String!) {
|
||||
destination_overview_page(uid: $uid, locale: $locale) {
|
||||
page_settings {
|
||||
hide_booking_widget
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query GetHotelPageSettings($uid: String!, $locale: String!) {
|
||||
hotel_page(uid: $uid, locale: $locale) {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#import "../../Fragments/Breadcrumbs/Breadcrumbs.graphql"
|
||||
#import "../../Fragments/System.graphql"
|
||||
|
||||
query GetDestinationOverviewPageBreadcrumbs($locale: String!, $uid: String!) {
|
||||
destination_overview_page(locale: $locale, uid: $uid) {
|
||||
web {
|
||||
breadcrumbs {
|
||||
...Breadcrumbs
|
||||
}
|
||||
}
|
||||
system {
|
||||
...System
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query GetDestinationOverviewPageBreadcrumbsRefs(
|
||||
$locale: String!
|
||||
$uid: String!
|
||||
) {
|
||||
destination_overview_page(locale: $locale, uid: $uid) {
|
||||
web {
|
||||
breadcrumbs {
|
||||
...BreadcrumbsRefs
|
||||
}
|
||||
}
|
||||
system {
|
||||
...System
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#import "../../Fragments/System.graphql"
|
||||
|
||||
query GetDestinationOverviewPage($locale: String!, $uid: String!) {
|
||||
destination_overview_page(uid: $uid, locale: $locale) {
|
||||
title
|
||||
url
|
||||
system {
|
||||
...System
|
||||
created_at
|
||||
updated_at
|
||||
}
|
||||
}
|
||||
trackingProps: destination_overview_page(locale: "en", uid: $uid) {
|
||||
url
|
||||
}
|
||||
}
|
||||
|
||||
query GetDestinationOverviewPageRefs($locale: String!, $uid: String!) {
|
||||
destination_overview_page(locale: $locale, uid: $uid) {
|
||||
system {
|
||||
...System
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query GetDaDeEnUrlsDestinationOverviewPage($uid: String!) {
|
||||
de: destination_overview_page(locale: "de", uid: $uid) {
|
||||
url
|
||||
}
|
||||
en: destination_overview_page(locale: "en", uid: $uid) {
|
||||
url
|
||||
}
|
||||
da: destination_overview_page(locale: "da", uid: $uid) {
|
||||
url
|
||||
}
|
||||
}
|
||||
|
||||
query GetFiNoSvUrlsDestinationOverviewPage($uid: String!) {
|
||||
fi: destination_overview_page(locale: "fi", uid: $uid) {
|
||||
url
|
||||
}
|
||||
no: destination_overview_page(locale: "no", uid: $uid) {
|
||||
url
|
||||
}
|
||||
sv: destination_overview_page(locale: "sv", uid: $uid) {
|
||||
url
|
||||
}
|
||||
}
|
||||
18
lib/graphql/Query/DestinationOverviewPage/Metadata.graphql
Normal file
18
lib/graphql/Query/DestinationOverviewPage/Metadata.graphql
Normal file
@@ -0,0 +1,18 @@
|
||||
#import "../../Fragments/Metadata.graphql"
|
||||
#import "../../Fragments/System.graphql"
|
||||
|
||||
query GetDestinationOverviewPageMetadata($locale: String!, $uid: String!) {
|
||||
destination_overview_page(locale: $locale, uid: $uid) {
|
||||
web {
|
||||
breadcrumbs {
|
||||
title
|
||||
}
|
||||
seo_metadata {
|
||||
...Metadata
|
||||
}
|
||||
}
|
||||
system {
|
||||
...System
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#import "../Fragments/System.graphql"
|
||||
|
||||
query ResolveEntryByUrl($locale: String!, $url: String!) {
|
||||
query EntryByUrlBatch1($locale: String!, $url: String!) {
|
||||
all_account_page(where: { url: $url }, locale: $locale) {
|
||||
items {
|
||||
system {
|
||||
@@ -50,3 +50,14 @@ query ResolveEntryByUrl($locale: String!, $url: String!) {
|
||||
total
|
||||
}
|
||||
}
|
||||
|
||||
query EntryByUrlBatch2($locale: String!, $url: String!) {
|
||||
all_destination_overview_page(where: { url: $url }, locale: $locale) {
|
||||
items {
|
||||
system {
|
||||
...System
|
||||
}
|
||||
}
|
||||
total
|
||||
}
|
||||
}
|
||||
|
||||
41
lib/graphql/batchEdgeRequest.ts
Normal file
41
lib/graphql/batchEdgeRequest.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import deepmerge from "deepmerge"
|
||||
|
||||
import { arrayMerge } from "@/utils/merge"
|
||||
|
||||
import { edgeRequest } from "./edgeRequest"
|
||||
|
||||
import type { BatchRequestDocument } from "graphql-request"
|
||||
|
||||
import type { Data } from "@/types/request"
|
||||
|
||||
export async function batchEdgeRequest<T>(
|
||||
queries: BatchRequestDocument[]
|
||||
): Promise<Data<T>> {
|
||||
try {
|
||||
const response = await Promise.allSettled(
|
||||
queries.map((query) => edgeRequest<T>(query.document, query.variables))
|
||||
)
|
||||
|
||||
let data = {} as T
|
||||
const reasons: PromiseRejectedResult["reason"][] = []
|
||||
response.forEach((res) => {
|
||||
if (res.status === "fulfilled") {
|
||||
data = deepmerge(data, res.value.data, { arrayMerge })
|
||||
} else {
|
||||
reasons.push(res.reason)
|
||||
}
|
||||
})
|
||||
|
||||
if (reasons.length) {
|
||||
reasons.forEach((reason) => {
|
||||
console.error(`Batch request failed`, reason)
|
||||
})
|
||||
}
|
||||
|
||||
return { data }
|
||||
} catch (error) {
|
||||
console.error("Error in batched graphql request")
|
||||
console.error(error)
|
||||
throw new Error("Something went wrong")
|
||||
}
|
||||
}
|
||||
@@ -170,3 +170,9 @@ export const getMeetingRooms = cache(
|
||||
return serverClient().hotel.meetingRooms(input)
|
||||
}
|
||||
)
|
||||
|
||||
export const getDestinationOverviewPage = cache(
|
||||
async function getMemoizedDestinationOverviewPage() {
|
||||
return serverClient().contentstack.destinationOverviewPage.get()
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user