I’m using graphql in Vue and I came up with this problem!
This is my code for calling graphql in store:
async fetchBookContent({ commit }, data) {
let token = data.token
let bookId = data.bookId
const ALL_BOOKS_QUERIES = gql`
query {
book(args:{token:${token},bookId:${bookId}}){
information{
name
}
}
}
`
const { result } = useQuery(ALL_BOOKS_QUERIES)
console.log(result)
commit('content', result)
},
I need to pass token and bookId I guess, but it keeps giving me syntax error 🙁
does anyone know the problem?
query($token: String, $bookId: String!){
book(args:{token: $token, bookId: $bookId}){
information{
name
}
contents{
name
stats{
mcQuiz
}
}
}
}
BTW, this is the query I must write the code for
1
Consult the Apollo documentation which goes over how to use variables with graphql (they get added as a second parameter of useQuery).
51 mins ago