Merged in feat/footer (pull request #11)
Feat/footer * chore: correct type * fix: remove redundant return type * chore: align code formatting * chore: format code to avoid diffing noise * chore: clean up format diffing noise * chore: move props tying to types folder * fix: update app_downloads usage and types * fix: improve footer query and typings * refactor: add Image.graphql * fix: correct typings
This commit is contained in:
committed by
Simon.Emanuelsson
parent
7926568eae
commit
2bd4e25403
@@ -19,7 +19,7 @@ fragment ListItemExternalLink on CurrentBlocksPageBlocksListBlockListItemsListIt
|
||||
}
|
||||
}
|
||||
|
||||
fragment ListItemInternalLink on CurrentBlocksPageBlocksListBlockListItemsListItemInternalLink {
|
||||
fragment ListItemInternalLink on CurrentBlocksPageBlocksListBlockListItemsListItemInternalLink {
|
||||
list_item_internal_link {
|
||||
link_text
|
||||
list_item_style
|
||||
@@ -39,7 +39,7 @@ fragment ListItemInternalLink on CurrentBlocksPageBlocksListBlockListItemsListI
|
||||
fragment ListBlock on CurrentBlocksPageBlocksList {
|
||||
list {
|
||||
list_items {
|
||||
__typename
|
||||
__typename
|
||||
...ListItem
|
||||
...ListItemExternalLink
|
||||
...ListItemInternalLink
|
||||
|
||||
27
lib/graphql/Fragments/Footer/AppDownloads.graphql
Normal file
27
lib/graphql/Fragments/Footer/AppDownloads.graphql
Normal file
@@ -0,0 +1,27 @@
|
||||
#import "../Image.graphql"
|
||||
|
||||
fragment AppDownloads on Footer {
|
||||
app_downloads {
|
||||
title
|
||||
app_store {
|
||||
href
|
||||
imageConnection {
|
||||
edges {
|
||||
node {
|
||||
...Image
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
google_play {
|
||||
href
|
||||
imageConnection {
|
||||
edges {
|
||||
node {
|
||||
...Image
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
lib/graphql/Fragments/Footer/Logo.graphql
Normal file
10
lib/graphql/Fragments/Footer/Logo.graphql
Normal file
@@ -0,0 +1,10 @@
|
||||
fragment Logo on Footer {
|
||||
logoConnection {
|
||||
edges {
|
||||
node {
|
||||
title
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
34
lib/graphql/Fragments/Footer/Navigation.graphql
Normal file
34
lib/graphql/Fragments/Footer/Navigation.graphql
Normal file
@@ -0,0 +1,34 @@
|
||||
#import "../PageLinks.graphql"
|
||||
|
||||
fragment Navigation on Footer {
|
||||
navigation {
|
||||
links {
|
||||
... on FooterNavigationLinksInternalLink {
|
||||
__typename
|
||||
internal_link {
|
||||
link_text
|
||||
pageConnection {
|
||||
edges {
|
||||
node {
|
||||
__typename
|
||||
...TempPageLink
|
||||
...CurrentBlocksPageLink
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
... on FooterNavigationLinksExternalLink {
|
||||
__typename
|
||||
external_link {
|
||||
link {
|
||||
href
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
title
|
||||
}
|
||||
}
|
||||
17
lib/graphql/Fragments/Footer/SocialMedia.graphql
Normal file
17
lib/graphql/Fragments/Footer/SocialMedia.graphql
Normal file
@@ -0,0 +1,17 @@
|
||||
fragment SocialMedia on Footer {
|
||||
social_media {
|
||||
title
|
||||
facebook {
|
||||
href
|
||||
title
|
||||
}
|
||||
instagram {
|
||||
href
|
||||
title
|
||||
}
|
||||
twitter {
|
||||
href
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
14
lib/graphql/Fragments/Footer/TripAdvisor.graphql
Normal file
14
lib/graphql/Fragments/Footer/TripAdvisor.graphql
Normal file
@@ -0,0 +1,14 @@
|
||||
#import "../Image.graphql"
|
||||
|
||||
fragment TripAdvisor on Footer {
|
||||
trip_advisor {
|
||||
logoConnection {
|
||||
edges {
|
||||
node {
|
||||
...Image
|
||||
}
|
||||
}
|
||||
}
|
||||
title
|
||||
}
|
||||
}
|
||||
@@ -14,4 +14,4 @@ fragment Hero on Hero {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
lib/graphql/Fragments/Image.graphql
Normal file
13
lib/graphql/Fragments/Image.graphql
Normal file
@@ -0,0 +1,13 @@
|
||||
fragment Image on SysAsset {
|
||||
description
|
||||
dimension {
|
||||
height
|
||||
width
|
||||
}
|
||||
metadata
|
||||
title
|
||||
url
|
||||
system {
|
||||
uid
|
||||
}
|
||||
}
|
||||
26
lib/graphql/Query/Footer.graphql
Normal file
26
lib/graphql/Query/Footer.graphql
Normal file
@@ -0,0 +1,26 @@
|
||||
#import "../Fragments/Footer/AppDownloads.graphql"
|
||||
#import "../Fragments/Footer/Logo.graphql"
|
||||
#import "../Fragments/Footer/Navigation.graphql"
|
||||
#import "../Fragments/Footer/SocialMedia.graphql"
|
||||
#import "../Fragments/Footer/TripAdvisor.graphql"
|
||||
|
||||
query GetFooter($locale: String!) {
|
||||
all_footer(limit: 1, locale: $locale) {
|
||||
items {
|
||||
title
|
||||
system {
|
||||
locale
|
||||
uid
|
||||
}
|
||||
about {
|
||||
text
|
||||
title
|
||||
}
|
||||
...AppDownloads
|
||||
...Logo
|
||||
...Navigation
|
||||
...SocialMedia
|
||||
...TripAdvisor
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
import "server-only"
|
||||
import { request as graphqlRequest } from "graphql-request"
|
||||
|
||||
import { env } from "@/env/server.mjs"
|
||||
|
||||
import type { Data } from "@/types/request"
|
||||
import type { DocumentNode } from "graphql";
|
||||
import type { DocumentNode } from "graphql"
|
||||
|
||||
export async function request<T>(query: string | DocumentNode, variables?: {}): Promise<Data<T>> {
|
||||
try {
|
||||
@@ -17,7 +16,7 @@ export async function request<T>(query: string | DocumentNode, variables?: {}):
|
||||
print(query as DocumentNode),
|
||||
variables,
|
||||
{
|
||||
"access_token": env.CMS_ACCESS_TOKEN,
|
||||
access_token: env.CMS_ACCESS_TOKEN,
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
)
|
||||
@@ -25,8 +24,12 @@ export async function request<T>(query: string | DocumentNode, variables?: {}):
|
||||
/**
|
||||
* TODO: Send to Monitoring (Logging and Metrics)
|
||||
*/
|
||||
console.log({ complexityLimit: rawResponse.headers.get("x-query-complexity") })
|
||||
console.log({ referenceDepth: rawResponse.headers.get("x-reference-depth") })
|
||||
console.log({
|
||||
complexityLimit: rawResponse.headers.get("x-query-complexity"),
|
||||
})
|
||||
console.log({
|
||||
referenceDepth: rawResponse.headers.get("x-reference-depth"),
|
||||
})
|
||||
console.log({ resolverCost: rawResponse.headers.get("x-resolver-cost") })
|
||||
|
||||
return {
|
||||
@@ -37,7 +40,7 @@ export async function request<T>(query: string | DocumentNode, variables?: {}):
|
||||
const response = await graphqlRequest<T>({
|
||||
document: query,
|
||||
requestHeaders: {
|
||||
"access_token": env.CMS_ACCESS_TOKEN,
|
||||
access_token: env.CMS_ACCESS_TOKEN,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
url: env.CMS_URL,
|
||||
@@ -49,4 +52,4 @@ export async function request<T>(query: string | DocumentNode, variables?: {}):
|
||||
console.error(error)
|
||||
throw new Error("Something went wrong")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user