loona
loona copied to clipboard
PatchFragment with nested fragments
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
Also having this problem with nested fragments, did you come up with a solution?