-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
UnexpectedObjectType #148
Comments
I did some digging and turns out this is the same problem as in this closed issue #109, with missing data when our graphql server returns errors |
To be more specific this is the data response, which isn't completely missing:
It might be useful to be able to configure the client to just return errors if they are encountered and to not try and parse the data, as not all GraphQL servers seem to stick to the official contract |
I've worked around this for now by executing the query manually and then throwing any errors that are found before decoding - client.query(selection, policy: policy)
+ client.executeQuery(for: selection, policy: policy)
+ .tryMap { result in
+ if let error = result.error {
+ throw error // new line that client.query doesn't do
+ }
+ return try result.decode(selection: selection)
+ } |
@yonaskolb which file is that? I'll prepare a PR and merge this right away 😄 |
|
As I mentioned in the PR, I made some assumptions before that evidently no longer hold. This issue has been resolved, but the API isn't as good as I want it to be. Instead of delaying a release, I released an imperfect version that should solve the problem for now, but I want to address the overarching issue better in the next release. I am leaving this issue open as a reminder and a reference to the PR. @yonaskolb thank you for opening this! |
Thank you for the quick fix @maticzav! 🙏 |
Sounds like this was resolved in a separate PR so I'm closing for now. Moving forwards I will open a Discussion regarding error handling and scenarios where data may be missing etc. |
Hi, this library looks great! I've integrated it into a codebase to replace Apollo, but after running it for the first time I'm getting the error
unexpectedObjectType(expected: "Dictionary", received: <null>)
on the first query. I do notice that other queries do work, so not sure what the issue is. How do I go about diagnosing this?within
OperationResult.decode<T, TypeLock>(selection: Selection<T, TypeLock>) throws -> DecodedOperationResult<T>
This is the query
Here's some of the code I'm using. Not sure what you need.
The text was updated successfully, but these errors were encountered: