3

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?

Sasha Zoria
  • 739
  • 1
  • 9
  • 28
  • Could you please be more specific with what error or output you are getting that is unexpected – Austio Sep 09 '18 at 13:27
  • Missing test attribute on result {books: Array(7), Symbol(id): "ROOT_QUERY"} This error occurs in the console – Sasha Zoria Sep 09 '18 at 13:34
  • What happens when you post that query into graphiql and try the query manually? Side note: don't need to specify `query` in the graphql-tag – Austio Sep 09 '18 at 17:02

1 Answers1

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
}
maersu
  • 3,242
  • 22
  • 27