There is a
Both should return PlayerType and both receive object with property profileId.
PlayerType has property profile with resolver:
profile: {
type: ProfileType,
resolve: (obj, args, {db}) => {
return db.collection('profiles').findOne({_id: ObjectID(obj.profileId)})
}
}
When server is asked for query player it returns both fields from players table and profile object with profile fields.
But when subscription below:
playerJoinedTable: {
type: PlayerType,
resolve: payload => payload,
subscribe: () => pubsub.asyncIterator('playerJoinedTable')
is executed, the server returns only player's own fields without executing profile's resolver.
Any idea why the subscription doesn't execute nested resolver?
Oskar!
Looks like you have an error in the playerJoinedTable > profile
resolver.
Seems that you're trying to access the collection
on db
(i think), but db
is undefined.
Make sure the server doesn't start listening before you pass db
to the context