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
Describe the issue
Using writeFragment with a fragment on interface fields causes the __typename of the concrete type implementing the interface to become: __typename: InterfaceName.
To Reproduce (MUST BE PROVIDED)
Let's suppose we have the following DSL:
interface Post {
title: String!
createdAt: String!
}
type LinkPost implements Post {
title: String!
createdAt: String!
linkUrl: String!
}
type TextPost implements Post {
title: String!
createdAt: String!
bodyText: String!
}
Now we provide the following dataIdFromObject function to the graphql cache:
When calling writeFragment, the cache is updated with with wrong typename(and. the correct new value for "title"):
c8e82094: {__typename: Post, id: c8e82094-6093-4df5-be2b-c1dc853d5071, title: 'New Title'}
Here, we see that __typename is incorrect and uses the name of the interface.
Expected behavior
The cache should preserve the cache entry of the concrete type (TextPost which already exists in the cache) based on its id, and only update the entry's field title
The text was updated successfully, but these errors were encountered:
ghost
changed the title
writeFragment on interface fields causes an incorrect change in __typename
[BUG] writeFragment on interface fields causes an incorrect change in __typename
Sep 24, 2023
Describe the issue
Using
writeFragment
with a fragment on interface fields causes the__typename
of the concrete type implementing the interface to become:__typename: InterfaceName
.To Reproduce (MUST BE PROVIDED)
Let's suppose we have the following DSL:
Now we provide the following
dataIdFromObject
function to the graphql cache:Now we want to update the "title" field for an entity in the cache and we go with the following:
Before calling
writeFragment
, the cache entry in question looks like this:c8e82094: {__typename: TextPost, id: c8e82094-6093-4df5-be2b-c1dc853d5071, title: 'Title'}
When calling
writeFragment
, the cache is updated with with wrong typename(and. the correct new value for "title"):c8e82094: {__typename: Post, id: c8e82094-6093-4df5-be2b-c1dc853d5071, title: 'New Title'}
Here, we see that
__typename
is incorrect and uses the name of the interface.Expected behavior
The cache should preserve the cache entry of the concrete type (TextPost which already exists in the cache) based on its id, and only update the entry's field
title
c8e82094: {__typename: TextPost, id: c8e82094-6093-4df5-be2b-c1dc853d5071, title: 'New Title'}
device / execution context
iOs simulator on Mac.
The text was updated successfully, but these errors were encountered: