Cleanup GraphQL query and add types

This commit is contained in:
2022-06-01 20:10:59 +02:00
parent e1d9e0bd50
commit 9ac9301540

View File

@@ -63,9 +63,10 @@
<SVGSprite />
<script context="module" lang="ts">
import type { LoadEvent, LoadOutput } from '@sveltejs/kit'
import { fetchAPI } from '$utils/api'
export async function load ({ url, params, fetch, session, stuff }) {
export async function load ({}: LoadEvent): Promise<LoadOutput> {
const res = await fetchAPI(`
query {
locations: location (filter: { status: { _eq: "published" }}) {
@@ -80,7 +81,10 @@
continent { slug }
}
date_updated
photos (sort: "-date_created", limit: ${import.meta.env.VITE_PREVIEW_COUNT}) {
photos (
sort: "-date_created",
limit: ${import.meta.env.VITE_PREVIEW_COUNT}
) {
image {
id
title
@@ -132,17 +136,13 @@
}
# Count
countPhotos: photo_aggregated (
filter: { status: { _eq: "published" }},
) {
countPhotos: photo_aggregated (filter: { status: { _eq: "published" }}) {
count { id }
}
countLocations: location_aggregated (
filter: { status: { _eq: "published" }},
) {
countLocations: location_aggregated (filter: { status: { _eq: "published" }}) {
count { id }
}
countCountries: country_aggregated {
countCountries: country_aggregated (filter: { status: { _eq: "published" }}) {
count { id }
}
}