Make GraphQL queries more compact
This commit is contained in:
@@ -159,38 +159,36 @@
|
||||
const loadPhotos = async (page: number) => {
|
||||
const res = await fetch('/api/data', {
|
||||
method: 'POST',
|
||||
body: `
|
||||
query {
|
||||
photos: photo (
|
||||
filter: {
|
||||
${filterCountry !== 'all' ? `location: { country: { slug: { _eq: "${filterCountry}" }} },` : ''}
|
||||
status: { _eq: "published" },
|
||||
},
|
||||
sort: "${filterSort === 'latest' ? '-' : ''}date_created",
|
||||
limit: ${PUBLIC_GRID_INCREMENT},
|
||||
page: ${page},
|
||||
) {
|
||||
body: `query {
|
||||
photos: photo (
|
||||
filter: {
|
||||
${filterCountry !== 'all' ? `location: { country: { slug: { _eq: "${filterCountry}" }} },` : ''}
|
||||
status: { _eq: "published" },
|
||||
},
|
||||
sort: "${filterSort === 'latest' ? '-' : ''}date_created",
|
||||
limit: ${PUBLIC_GRID_INCREMENT},
|
||||
page: ${page},
|
||||
) {
|
||||
id
|
||||
title
|
||||
slug
|
||||
image {
|
||||
id
|
||||
title
|
||||
}
|
||||
location {
|
||||
slug
|
||||
image {
|
||||
id
|
||||
title
|
||||
}
|
||||
location {
|
||||
name
|
||||
region
|
||||
country {
|
||||
slug
|
||||
name
|
||||
region
|
||||
country {
|
||||
slug
|
||||
name
|
||||
flag { id }
|
||||
}
|
||||
flag { id }
|
||||
}
|
||||
city
|
||||
}
|
||||
city
|
||||
}
|
||||
`,
|
||||
}`,
|
||||
})
|
||||
|
||||
const { data: { photos }} = await res.json()
|
||||
|
||||
Reference in New Issue
Block a user