Skip to content
This repository has been archived by the owner on Nov 23, 2020. It is now read-only.

PatchFragment with nested fragments #301

Open
david-on-github opened this issue Jan 2, 2019 · 1 comment
Open

PatchFragment with nested fragments #301

david-on-github opened this issue Jan 2, 2019 · 1 comment
Labels
bug Something isn't working core Related to @loona/core

Comments

@david-on-github
Copy link

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

@kamilkisiela kamilkisiela added bug Something isn't working core Related to @loona/core labels Jan 3, 2019
@trompx
Copy link

trompx commented Sep 15, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working core Related to @loona/core
Projects
None yet
Development

No branches or pull requests

3 participants