You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered an issue with handling custom scalars. I am using autogenerated type policies to convert ISO8601 strings into Duration and DateTime objects.
Here is my type policies example:
I encountered a strange behavior where some requests from the server are handled correctly, and I see DateTime and Duration objects in the logs. However, in some cases, I see plain strings that the server returns (checked in the network tab).
As a result, the entire application crashes (because I use objects for human-readable date representations), and the plain strings naturally do not have such functions.
Yes, I understand that I can modify the prototype of strings to convert everything into the format I need upon calling the function and then return the result, and I can also check the types and do regular branching, but all this seems not correct way to fix this behaviour. What could be causing this strange behavior of apolloClient, and is there any way to fix it?
The text was updated successfully, but these errors were encountered:
I also forgot to mention that I added logging to the read function and verified its calls in the source code. Everything appears to be correct: the raw value is the one returned by the server, the constructed objects are accurate, and the returned values are as expected. However, the data object still contains plain strings.
That certainly seems off. Could you try to create a minimal reproduction, e.g. as a CodeSandbox?
Unfortunately, I have not been able to reproduce this bug. Moreover, subsequent tests of the main system resulted in the behaviour changing to normal. Of course I'm a little concerned that this is a potentially floating bug, but for now I'll consider it an unfortunate coincidence of my operating system. I think the topic can be closed. If it happens again, I'll write back.
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.
I encountered an issue with handling custom scalars. I am using autogenerated type policies to convert ISO8601 strings into Duration and DateTime objects.
Here is my type policies example:
I use the useQuery hook to fetch data:
I encountered a strange behavior where some requests from the server are handled correctly, and I see DateTime and Duration objects in the logs. However, in some cases, I see plain strings that the server returns (checked in the network tab).
As a result, the entire application crashes (because I use objects for human-readable date representations), and the plain strings naturally do not have such functions.
Yes, I understand that I can modify the prototype of strings to convert everything into the format I need upon calling the function and then return the result, and I can also check the types and do regular branching, but all this seems not correct way to fix this behaviour. What could be causing this strange behavior of apolloClient, and is there any way to fix it?
The text was updated successfully, but these errors were encountered: