问题
I can't understand why this error occurs in the console
import gql from 'graphql-tag' // import gql
const getBooksQuery = gql`query // describing query
{
books{
name
id
}
}
`;
export default {
name: "BookList", // template name
apollo: { // apollo instance
query: getBooksQuery // query
}
}
What am i doing wrong?
回答1:
You have to name the apollo property (docs, e.g bookList
):
export default {
name: "BookList", // template name
apollo: {
bookList: {
query: getBooksQuery // query
}
}
}
or even simpler (when you don't need any configs)
apollo: {
bookList: getBooksQuery
}
来源:https://stackoverflow.com/questions/52244874/missing-query-attribute-on-result-vue-graphql