-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Cannot return null for non-nullable field
when throwing error
#5550
Comments
type User { make Id nullable. that should return just the error that you are expecting |
Sorry, did not notice the issue was on Query.permissions. Are you sure that permissions results in a valid response. Looks like it yields in a null and hence is complaining about the schema being not optional |
@cactusblew That seems to be correct, but in this case, it's returning null because the other part of the query is erroring. It seems weird that errors aren't propagated correctly here, as the error is causing another error (when it should only be returning the original error) |
If you expect After all, if you ran the query |
@glasser This is not the behavior that's being described here.
I've updated the OP to clarify this. This still seems to be a bug. |
Well, I didn't see your code, so I didn't know that. If you'd like us to look more into it, we need to see the whole code: something we can git clone or on codesandbox.io, say. |
@glasser I will provide an example tomorrow! |
Been trying to replicate for a while with no luck. Somehow no longer getting the error in the application (had found a workaround I think) too. If I can find a way to reproduce it again, I should be able to translate it to my Codesandbox. Thanks! |
I think the issue you're talking about is the one I describe at apollographql/federation#159 (comment) |
@glasser Yes that seems similar to what was my issue! |
@glasser This broke our frontend as well, we now have two errors which are getting shown. One is meaningful but the second is always "cannot return null for a non-nullable field". Is a new issue needed? I can attempt a fix |
…xecute (#159)" This reverts commit 9045f55, which was from #159. See the comment in #981 which explains the justification as well, but briefly: While that PR was an improvement in principle, it: - has a bug that was first captured in #159 (comment) To quote that here: > I think there's a bug here. Let's say we have a query `{ x }` where `x` is a non-nullable field, and the federated execution has `x` throw an error. This turns all of `data` into `null` (not `{ x: null }`). But then this re-execution adds another error saying that the non-null field is null. > > Take a look at https://codesandbox.io/s/angry-raman-uuzuf?file=/src/index.js for an example of what's going on here. - Sometimes — unexpectedly to current users, at least — breaks client expectations. As of now, the pain points seem to be outweighing the gains. We'll need to revert this and revisit this when time allows with a slightly different approach and #981 tracks the need to do so. Ref: #159 Ref: apollographql/apollo-server#5550 Ref: #974 Ref: apollographql/apollo-server#4523
…xecute (#159)" (#982) This reverts commit 9045f55, which was from #159. See the comment in #981 which explains the justification as well, but briefly: While that PR was an improvement in principle, it: - has a bug that was first captured in #159 (comment) To quote that here: > I think there's a bug here. Let's say we have a query `{ x }` where `x` is a non-nullable field, and the federated execution has `x` throw an error. This turns all of `data` into `null` (not `{ x: null }`). But then this re-execution adds another error saying that the non-null field is null. > > Take a look at https://codesandbox.io/s/angry-raman-uuzuf?file=/src/index.js for an example of what's going on here. - Sometimes — unexpectedly to current users, at least — breaks client expectations. As of now, the pain points seem to be outweighing the gains. We'll need to revert this and revisit this when time allows with a slightly different approach and #981 tracks the need to do so. Ref: #159 Ref: apollographql/apollo-server#5550 Ref: #974 Ref: apollographql/apollo-server#4523
Apollo Gateway: 0.33.0
Apollo Federation: 0.26.0
Apollo Server: 3.0.1
I have a federated graph, with a service with the following schema:
In my resolver, it's defined roughly like:
With the following query:
Actual
When querying
me
withoutctx.user
set, it returns 2 errors instead of 1.Errors:
Expected
I believe it should only return a different error.
Errors:
The text was updated successfully, but these errors were encountered: