Missing query attribute on result Vue graphql

两盒软妹~` 提交于 2021-02-09 10:53:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!