我正在使用vue-apollo,目前遇到问题:
<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 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 {
......
}
答案 0 :(得分:0)
运行:
npm install --no-save apollo-utilities@1.0.22
为我解决了这个问题。参见https://github.com/apollographql/apollo-client/issues/4125