Make GraphQL queries more compact

This commit is contained in:
2022-08-16 21:17:14 +02:00
parent 52e0407700
commit 0e6aaaa4e2
14 changed files with 435 additions and 471 deletions

View File

@@ -6,50 +6,48 @@ import { getProducts } from '$utils/functions/swell'
export const load: PageServerLoad = async () => {
try {
// Get content from API
const res = await fetchAPI(`
query {
shop {
page_heroimage { id }
}
const res = await fetchAPI(`query {
shop {
page_heroimage { id }
}
location (
filter: {
has_poster: { _eq: true },
status: { _eq: "published" },
},
sort: "name"
) {
location (
filter: {
has_poster: { _eq: true },
status: { _eq: "published" },
},
sort: "name"
) {
name
slug
}
posters: product (
filter: { status: { _eq: "published" }}
) {
name
type
description
details
location {
name
slug
}
posters: product (
filter: { status: { _eq: "published" }}
) {
name
type
description
details
location {
name
slug
product_id
photos_product {
directus_files_id {
id
title
}
product_id
photos_product {
directus_files_id {
id
title
}
}
photos_preview {
directus_files_id {
id
title
}
}
photos_preview {
directus_files_id {
id
title
}
}
}
`)
}`)
const { data: { shop, location, posters }} = res