-
Notifications
You must be signed in to change notification settings - Fork 49
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
How to create an optimisticResponse
for a mutation returning union
type?
#321
Comments
I just saw #316, so I don't know if this that I wrote was affected by that PR... |
@reck753 haha, the timing! You are absolutely correct that this was indeed a bug that #316 fixed. The fix has been released in Sorry for the inconvenience! |
The timing is incredible! My bad for not checking what was done in the meantime 😅 Thanks a lot! Will try it and let you know! |
@reck753 yes please try it and let me know! It's embarrassing this bug has been sitting around for this long 😬 And thank you for posting good questions with great background info - my goal is for RescriptRelay to be as ergonomic as I can make it, so you're definitively encouraged to keep posting things like this any time you find something that feels hard/cumbersome/unclear. Thanks! |
@zth I just tried it and it works like a charm! Thank you! It's not embarrassing at all. The thing you do for us is pretty hard, so we can't be mad if something is missing out, especially when you are quick to fix it! It is easier for everyone to make precise and well explained issues, even if it takes some time doing so. So, definitely, if there is something to be asked, I will be descriptive! 😄 |
Hi!
Question setup
Question
As you already know,
union
type is translated topolymorphic variant
and hence theoptimisticResponse
, of a mutation returningunion
type, expects the same thing. However, by doing so:we would get this error:
which completely makes sense since
NAME/VAL
object is howpolymorphic variant
is being translated to JS.We also tried doing something unsafe like this:
but that would return this error:
We are wondering if there is any type safe solution for this?
Apart from that having it is pretty hard to make
optimisticResponse
as well:As a solution, we could change
Post
be aninterface
, which probably makes sense for this example, and takeid
andliked
as common fields and avoid having inline fragments at all. However, this would be a workaround, since we might stumble on a case where we wouldn't have any common fields (#315), and we might get the same result as withunion
since, in that case,interface
would be translated topolymorphic variant
as well.Thanks in advance and sorry for yet another long question/issue...
The text was updated successfully, but these errors were encountered: