-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Sometimes the same fragment is added to a query twice #897
Comments
Could you file this on The above looks like a bug, where we are accidentally appending the fragment twice. Can you reproduce some of your code here? Where you are running the query and setting the variables, etc? |
Thanks @stubailo (other issue here apollographql/react-apollo#323): Child Item:
Parent List:
NOTE: I was expecting to be able to parameterize "...ItemFragment" so that optional parts of the the parent's query can be passed down; for example something like:
|
Temporary workaround:
|
Great workaround. If you could submit a failing test that would be super helpful as well: https://github.com/apollostack/apollo-client/blob/dc8cc0063d93a8c15a90771bc88183bc058b5e1b/test/fetchMore.ts |
OK. I'll try to wrap my head around that and have a stab at it (might be closer to Monday though). Thanks for the comments. |
Yeah, we won't be able to get to a fix before Monday either. Thanks for the really detailed report! |
I had the same issue. The workaround for me was to explicitly specify the same query and fragments in the call to fetchMore. The problem is here:
In the Initially, the fragments were already added to the query in the When a variable for a query changes the |
Looks like the fix would be in here: https://github.com/apollostack/apollo-client/blob/372bca9881b374caf56d0cbd0795a88dcc13ec0f/src/queries/getFromAST.ts#L150 |
@stubailo are you suggesting that we "fix" this by checking whether a fragment with the same name already exists on the query? The other fix would be not to attach it twice in the first place. I'm leaning towards a simple fix for now, because we'll soon want to refactor how we transform queries anyway. |
@helfer see #906 for a (fairly) simple fix for this particular issue (which is not attaching it twice in the first place) warnings about fragment name collisions are already being surfaced in createFragment |
Solved in #913 |
I have a parent container List that renders a list of child container Items. I also have pagination working (i.e., a fetchMore property that implements an updateQuery function).
However, if I change the value of one of the query variables (e.g., a "text" filter) then paging causes an error (the Item fragment is included twice as below).
From my experience with Relay, the parent query variables should be used to parameterize the fragment, but I don't know if that's relevant here, or possible (e.g., ${Item.getFragment('item', { filter: variables.filter })})
Unrelated, but one disadvantage of the convention to put fragments as static members of the component is you can't reference these from static propTypes {} member functions.
The text was updated successfully, but these errors were encountered: