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 /> <SVGSprite />
<script context="module" lang="ts"> <script context="module" lang="ts">
import type { LoadEvent, LoadOutput } from '@sveltejs/kit'
import { fetchAPI } from '$utils/api' 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(` const res = await fetchAPI(`
query { query {
locations: location (filter: { status: { _eq: "published" }}) { locations: location (filter: { status: { _eq: "published" }}) {
@@ -80,7 +81,10 @@
continent { slug } continent { slug }
} }
date_updated 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 { image {
id id
title title
@@ -132,17 +136,13 @@
} }
# Count # Count
countPhotos: photo_aggregated ( countPhotos: photo_aggregated (filter: { status: { _eq: "published" }}) {
filter: { status: { _eq: "published" }},
) {
count { id } count { id }
} }
countLocations: location_aggregated ( countLocations: location_aggregated (filter: { status: { _eq: "published" }}) {
filter: { status: { _eq: "published" }},
) {
count { id } count { id }
} }
countCountries: country_aggregated { countCountries: country_aggregated (filter: { status: { _eq: "published" }}) {
count { id } count { id }
} }
} }