Skip to content

__typename is null when an optimistic update is applied #1230

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

Closed
calebmer opened this issue Jun 22, 2016 · 5 comments
Closed

__typename is null when an optimistic update is applied #1230

calebmer opened this issue Jun 22, 2016 · 5 comments

Comments

@calebmer
Copy link
Contributor

I have a Node that I want to update with an optimistic update, but that Node is also returned by a union so I need to get the __typename from the union. However, it would appear that after an optimistic update has been applied and before the response comes back, the value of that __typename on the union is null.

@josephsavona
Copy link
Member

Just to clarify, are you explicitly setting the __typename field in your optimistic response?

@calebmer
Copy link
Contributor Author

No

@calebmer
Copy link
Contributor Author

It does work when __typename is set in getOptimisticResponse though. Is this expected behavior?

@josephsavona
Copy link
Member

Yes, this is expected behavior. Relay can't know what type you meant to create within a union, so you have to specify it. It may be possible to infer the type in some cases that we don't today, but a union would always require it to be specified by the user.

@wincent
Copy link
Contributor

wincent commented Jun 23, 2016

Going to close this out, but feel free to comment again @calebmer if you'd like to know more. Thanks for bringing this up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants