-
-
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
Projection not being added to query in relation #376
Comments
Just to clarify, so when your query is like this: query UserById($_id: MongoID!) {
userById(_id: $_id) {
orgId
org {
name
}
}
} the response is like this: {
orgId: '123...',
org: {
name: 'theX',
}
} but when query is query UserById($_id: MongoID!) {
userById(_id: $_id) {
org {
name
}
}
} the response is {
org: null
} ❓ |
You may check this test suite with your code and it works perfectly: https://github.com/graphql-compose/graphql-compose-mongoose/blob/5a4a9f784c939cb4bb81ec90f8e01eb21a37888f/src/__tests__/github_issues/376-test.ts Just was made small changes according to v9.0.0: UserTC.addRelation('org', {
- resolver: () => OrgTC.getResolver('findById'),
+ resolver: () => OrgTC.mongoooseResolvers.findById(), Feel free to change this test in the new Pull Request if you want to provide a broken case. |
* Updated the test case for issue 376 so that it exposes at least one scenario where this error is occurring. I restructured the schema a bit and added further typings to mirror the schema I have been testing with. * Apparently the projection is added in some simple cases with findMany(), but when using findOne() (at a minimum), it appears to not work. There are now two tests: the first one fails (with findOne(), and the second one succeeds (with findMany()). * Updated to graphql-compose 9.0.8 to ensure testing is against the latest version. graphql-compose#376 graphql-compose/graphql-compose#382
I was running into similar issues here. I started playing around with the tests (which were working just fine) and adapted the test here for a scenario that is not working for me. I don't know if this is the only broken scenario (or if it matches the original broken scenario here), but at least it reveals the bug to be fixed. I created PR #403 with an updated test that shows a scenario where the I've isolated the test by running this command:
@nodkz, let me know if this is helpful or if you need any clarification... |
I have a schema with users that are part of an organization:
I am trying to set up a relation between the User and Org as such
However, the "orgId" projection is not added to the query and
source
does not containorgId
when I make queries-- thus returningnull
for the org.This is not an issue if I explicitly query for "orgId", but my understanding of the projection parameter is that it should be used for this exact reason-- so I don't need to explicitly query for "orgId".
What am I doing wrong?
The text was updated successfully, but these errors were encountered: