Make GraphQL queries more compact
This commit is contained in:
@@ -7,35 +7,33 @@ import { getRandomItem } from '$utils/functions'
|
||||
export const load: PageServerLoad = async ({}) => {
|
||||
try {
|
||||
// Get content from API
|
||||
const data = await fetchAPI(`
|
||||
query {
|
||||
posters: product (
|
||||
filter: { status: { _eq: "published" }}
|
||||
) {
|
||||
const data = await fetchAPI(`query {
|
||||
posters: product (
|
||||
filter: { status: { _eq: "published" }}
|
||||
) {
|
||||
name
|
||||
type
|
||||
description
|
||||
details
|
||||
location {
|
||||
name
|
||||
type
|
||||
description
|
||||
details
|
||||
location {
|
||||
name
|
||||
slug
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
`)
|
||||
}`)
|
||||
|
||||
if (data) {
|
||||
const randomPoster = getRandomItem(data.data.posters)
|
||||
|
||||
Reference in New Issue
Block a user