-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
Missing fields from projection in addRelation #377
Comments
@nodkz Thanks for the assist. I tried mirroring the exact same setup as in the test with no success. Have also tried mirror your server setup and mongoose config and that did not solve it either. Is there any way I can assist you in solving/finding the issue? I'll be more than happy to provide you with more details if you need it. |
In such case only repro repo can help. Can you please create a public repo with your setup? |
Pretty big repo but manage to crystallise the stuff so this is something that you should be able to test with. Do a classic yarn install + yarn dev and you should be good to go @nodkz Thanks again |
@trollcus thnx for repo. It was a very interesting investigation. In your repo, you are using Hopefully, it's easy to fix in your code moving PrevisitTC.addRelation('project', {
resolver: () => ProjectTC.mongooseResolvers.dataLoader({ lean: true }),
// resolver: () => ProjectTC.mongooseResolvers.dataLoader({ lean: true }),
prepareArgs: {
_id: source => {
return source.project_id || null
},
},
- projection: { project_id: true },
+ extensions: {
+ projection: { project_id: true },
+ },
}); This is why my tests were working correctly, but not working in your application. |
Please don't close this issue. I'll publish a fix in the near future which will allow using |
@nodkz BIG big thanks for the help. It worked when moving into extensions. Your work on these libraries is amazing. |
I had the same break when DiscriminatorTypeComposer had an addRelation that require a projection to provide an _id to a findById. BudgetModelModelTC.addRelation("package", { resolver: () => PackageModelTC.getResolver("findById"), prepareArgs: { _id: (source) => source.package, }, // see fixMissingProjections // https://github.com/graphql-compose/graphql-compose-mongoose/issues/377 extensions: { projection: { package: true }, }, }) |
I'm also using discriminators and this doesn't work for me, any updates on this? |
?? |
I am not using |
I have a discriminator called
However the projection on this discriminator ( The below relation on the base model of
|
Hi!
I'm having issues with the addRelation function. More specifically when projecting fields towards the graphql request. Worth noting is that this worked with the use of composeWithMongoose function previously.
Setup:
graphql-compose: "^9.0.3"
graphql-compose-mongoose: "^9.6.0"
mongoose: "5.13.8"
Code:
To further clarify.
Works while:
does not
All that I get from source is the field _id and it all results in that the project field is null. Any other field I query is undefined. Any ideas to why?
The text was updated successfully, but these errors were encountered: