diff --git a/app/composables/directus/useSolutionList.ts b/app/composables/directus/useSolutionList.ts index 8fe659f..fcbd25d 100644 --- a/app/composables/directus/useSolutionList.ts +++ b/app/composables/directus/useSolutionList.ts @@ -1,4 +1,4 @@ -import { readItems } from '@directus/sdk'; +import GetSolutionList from '@/graphql/solutionList.graphql?raw'; export const useSolutionList = () => { const { $directus } = useNuxtApp(); @@ -6,33 +6,8 @@ export const useSolutionList = () => { const locale = getDirectusLocale(); return useAsyncData(`solution-list-${locale}`, async () => { - return await $directus.request( - readItems('solutions', { - fields: [ - 'id', - 'cover', - { - type: ['id', { translations: ['id', 'name'] }, 'sort'], - }, - { - translations: ['id', 'title', 'summary'], - }, - ], - deep: { - type: { - translations: { - _filter: { - languages_code: { _eq: locale }, - }, - }, - }, - translations: { - _filter: { - languages_code: { _eq: locale }, - }, - }, - }, - }) - ); + return await $directus.query<{ solutions: Solution[] }>(GetSolutionList, { + locale: locale, + }); }); }; diff --git a/app/graphql/solutionList.graphql b/app/graphql/solutionList.graphql new file mode 100644 index 0000000..8422275 --- /dev/null +++ b/app/graphql/solutionList.graphql @@ -0,0 +1,21 @@ +query GetSolutionList($locale: String!) { + solutions { + id + cover { + id + } + type { + id + translations(filter: { languages_code: { code: { _eq: $locale } } }) { + id + name + } + sort + } + translations(filter: { languages_code: { code: { _eq: $locale } } }) { + id + title + summary + } + } +} diff --git a/app/pages/solutions/index.vue b/app/pages/solutions/index.vue index 33bf637..77442cd 100644 --- a/app/pages/solutions/index.vue +++ b/app/pages/solutions/index.vue @@ -54,7 +54,7 @@ const { data, pending, error } = await useSolutionList(); - const solutionsRaw = computed(() => data.value ?? []); + const solutionsRaw = computed(() => data.value.solutions ?? []); const solutions = computed(() => solutionsRaw.value.map((item) => toSolutionListView(item)) );