我正在工作 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 {
......
}