Fixes: 1) Correct missing semicolons in Pinia store definitions for cart, company, wishlist, and auth stores; 2) Refactor GraphQL queries to include fragments for improved modularity and readability; 3) Correct error handling in composables like `usePosts` and `useLanguages`; Extra: Enhanced App.vue to include dynamic company info and language fetching on mount; Added scoped styles for new components and pages.
20 lines
No EOL
453 B
JavaScript
20 lines
No EOL
453 B
JavaScript
import { useLazyQuery } from "@vue/apollo-composable";
|
|
import { GET_POSTS } from "@/graphql/queries/blog.js";
|
|
import {computed} from "vue";
|
|
|
|
export function usePosts() {
|
|
const { result, loading, error, load } = useLazyQuery(GET_POSTS);
|
|
|
|
const posts = computed(() => result.value?.posts.edges ?? []);
|
|
|
|
if (error.value) {
|
|
console.error("usePosts error:", error.value);
|
|
}
|
|
|
|
return {
|
|
posts,
|
|
loading,
|
|
error,
|
|
getPosts: load
|
|
};
|
|
} |