loona icon indicating copy to clipboard operation
loona copied to clipboard

PatchFragment with nested fragments

Open david-on-github opened this issue 7 years ago • 1 comments

When a fragment contains another fragment, patchFragment can't determine which fragment to read from.

fragment someFragment {
    id
    other {
      ...otherFragment
    }
}
ERROR Error: Uncaught (in promise): Error: Found 2 fragments. `fragmentName` must be provided when there is not exactly 1 fragment.
Error: Found 2 fragments. `fragmentName` must be provided when there is not exactly 1 fragment.
    at getFragmentQueryDocument (fragments.js:26)
    at InMemoryCache.push../node_modules/apollo-cache-inmemory/lib/inMemoryCache.js.InMemoryCache.readFragment (inMemoryCache.js:221)
    at ApolloClient.push../node_modules/apollo-client/ApolloClient.js.ApolloClient.readFragment (ApolloClient.js:124)
    at Object.patchFragment (loona.core.js:156)

Apollo cache readFragment takes fragmentName as an option to determine this. https://github.com/apollographql/apollo-client/blob/master/packages/apollo-cache/src/cache.ts#L80

david-on-github avatar Jan 02 '19 19:01 david-on-github

Also having this problem with nested fragments, did you come up with a solution?

trompx avatar Sep 15 '20 12:09 trompx