20 lines
No EOL
461 B
JavaScript
20 lines
No EOL
461 B
JavaScript
import { useLazyQuery } from "@vue/apollo-composable";
|
|
import {computed} from "vue";
|
|
import {GET_BRANDS} from "@/graphql/queries/brands.js";
|
|
|
|
export function useBrands() {
|
|
const { result, loading, error, load } = useLazyQuery(GET_BRANDS);
|
|
|
|
const brands = computed(() => result.value?.brands.edges ?? []);
|
|
|
|
if (error.value) {
|
|
console.error("useBrands error:", error.value);
|
|
}
|
|
|
|
return {
|
|
brands,
|
|
loading,
|
|
error,
|
|
getBrands: load
|
|
};
|
|
} |