Skip to content
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

getOptimisticResponse does not seem to populate __typename #618

Closed
Globegitter opened this issue Nov 20, 2015 · 2 comments
Closed

getOptimisticResponse does not seem to populate __typename #618

Globegitter opened this issue Nov 20, 2015 · 2 comments

Comments

@Globegitter
Copy link
Contributor

I have a mutation which returns an optimistic response as follows:

 getOptimisticResponse() {
    const {dateOfBirth, otherField, otherOtherField} = this.props;
    return {
      customer: {
        dateOfBirth,
        otherField,
        otherOtherField
      }
    };
  }

Which leads to: 'RelayQueryWriter: Could not find a type name for record%s.', here: 'RelayQueryWriter: Could not find a type name for record %s.',

When debugging I can see that the passed-in payload does not have a __typename. If I set it manually to Customer in the getOptimisticResponse the warning disappears.

I am using a version from master with the commit id 090b2b1c1228fb3337d8af68648b34150da682e6, so from about 2 days ago,

@josephsavona
Copy link
Contributor

@Globegitter thanks for filing this, see #621 for a fix

josephsavona added a commit that referenced this issue Nov 23, 2015
Summary: Addresses #618 - developers shouldn't have to write `__typename`s for optimistic records. `RelayQueryWriter` already traverses *any* fragment when handling optimistic payloads, and the other place where we would use the type - the cache writer - doesn't receive optimistic writes either.
Closes #621

Reviewed By: yungsters

Differential Revision: D2679773

fb-gh-sync-id: 1a07c36085a5fc23df9b1cf0daab9b77336b0b91
@josephsavona
Copy link
Contributor

@Globegitter thanks again 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

2 participants