mobilizon.chapril.org-mobil.../js/src/composition/apollo/tags.ts
Thomas Citharel ee20e03cc2
Migrate to Vue 3 and Vite
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2022-08-11 16:46:31 +02:00

19 lines
586 B
TypeScript

import { FILTER_TAGS } from "@/graphql/tags";
import { ITag } from "@/types/tag.model";
import { apolloClient } from "@/vue-apollo";
import { provideApolloClient, useQuery } from "@vue/apollo-composable";
export function fetchTags(text: string): Promise<ITag[]> {
return new Promise((resolve, reject) => {
const { onResult, onError } = provideApolloClient(apolloClient)(() =>
useQuery<{ tags: ITag[] }, { filter: string }>(FILTER_TAGS, {
filter: text,
})
);
onResult(({ data }) => resolve(data.tags));
onError((error) => reject(error));
});
}