Missing query attribute on result Vue graphql

Viewed 1268

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 Answers

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
}
Related