Add useQueryStore to handle GraphQL queries

This commit is contained in:
Dede Fuji Abdul
2024-01-08 10:25:21 +07:00
parent 1573672c84
commit 8228520851
4 changed files with 140 additions and 27 deletions

21
src/stores/queries.ts Normal file
View File

@ -0,0 +1,21 @@
import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import gql from 'graphql-tag'
import { useQuery } from '@apollo/client'
export const useQueryStore = defineStore('query', () => {
const getUser = useQuery(gql`
query getUsers {
users {
id
firstname
lastname
email
}
}
`)
return {
getUser,
}
})