结果Vue graphql上缺少查询属性 [英] Missing query attribute on result Vue graphql

查看:98
本文介绍了结果Vue graphql上缺少查询属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么控制台中会发生此错误

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

我在做什么错了?

推荐答案

您必须命名apollo属性(

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
}

这篇关于结果Vue graphql上缺少查询属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆