0

我正在工作 vue-apollo,目前我遇到了问题:

工作区.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>

查询.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 {
  ......
}

4

1 回答 1

0

跑步:

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

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

于 2019-01-28T15:04:33.673 回答