-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to populate items in array? #167
Comments
https://graphql-compose.github.io/docs/basics/understanding-relations.html#relation-via-resolver in your case it can look something like DocumentCollectionTC.getFieldOTC('items').addRelation('documents', {
resolver: () => DocumentTC.getResolver('findByIds'),
prepareArgs: {
_ids: source => source.documents || [],
},
projection: { documents: true },
}); |
Thank you @nodkz ! I grateful for this package, and the solution to this topic. Maybe add this to the README ?! This helped me tremendously. It might help others. |
@SabrinaDanielle sure 👍 Can you add it to the end of FAQ section? Tnx! |
@nodkz Does anyone know how to populate the same property? |
@danimayfield Did you try to use dataloader? DocumentCollectionTC.getFieldOTC('items').addRelation('documents', {
resolver: () => DocumentTC.mongooseResolvers.dataLoaderMany({ lean: true }),
prepareArgs: {
_ids: source => source.documents || [],
},
projection: { documents: true },
}); |
Yes I did, it turns out it's a discriminator issue and projection isn't working: #441 |
I have in mongoose document collection with an array of documents:
I need to do a query that returns all the objects (
findMany
) with items populated.The problem is items returns as an array of mongoids.
How to extend the
findMany
resolver to populate document object?This is my expected query:
Currently I getting this results:
@nodkz Is it something possible to do? because I can't find any working example.
The text was updated successfully, but these errors were encountered: