[vue-apollo]:查询getTeam

时间:2018-12-03 09:25:27

标签: graphql vue-apollo

我正在使用vue-apollo,目前遇到问题:

Workspace.vue

<script>
    import { GetTeam } from '../constants/query.gql'
    export default  {
        name: 'Workspace',
        data() {
            return {
                getTeam: {}
            }
        },
        apollo: {
            getTeam: {
                query: GetTeam
            }
        }
   }
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

query.gql

query GetTeam {
    getTeam {
       id
       name
    }
}

我遇到以下错误

  

[vue-apollo]:查询getTeam发生错误

是否可以解决此问题?

//resolvers.js
const resolvers = {
  Query: {
        async getTeam(_, args, context) {
            const userId = getUserId(context)
            const user = await User.findById(userId)
            return await Team.findById(user.team)
        }
}

//schema.graphql

type Team {
    id: String!
    name: String!
}

type User {
  ......
}

1 个答案:

答案 0 :(得分:0)

运行:

npm install --no-save apollo-utilities@1.0.22

为我解决了这个问题。参见https://github.com/apollographql/apollo-client/issues/4125