我有电影模式
type Movie {
id: ID
title: String
watchedBy: [User]!
watchedCount: Int
}
解析器:
Query: {
listMovies: async (_, __, { dataSources }) => {
return await dataSources.movieAPI.getAllMovies()
},
},
Movie: {
watchedBy: async (listMovie, __, { dataSources }) => {
return await dataSources.userAPI.getWatchedByUsers(listMovie.id)
}
}
如果我想退回watchedCount
怎么办?如何访问watchedBy
,以便退回watchedBy.length
?还是应该在前端计算watchedBy.length
?