Noob here. I created a custom resolver on graphql and the function for that resolver filters and counts each type of one field. This is the code:
result = await collection.aggregate([
{ $match: { post_id: input.post_id} },
{ $group: { _id: '$unicode', count: { $sum: 1 } } },
{ $project: { unicode: '$_id', count: 1, _id: 0 } }
]).toArray();
This function works when I test it under the console with non-system users and also on graphiql. But when I fetch the data from the client side it is giving this error.
Error aggregating reactions: FunctionError: intermediate aggregation document does not satisfy schema: reason=“could not validate document: \n\t(root): user_id is required\n\t(root): post_id is required\n\t(root): _id is required”; code=“SchemaValidationFailedRead”; untrusted=“read not permitted”; details=map
I don’t see the reason for requiring user_id and _id as I am not using to query or filter the collection. Appreciate any help