-
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
Test: noFetch with inline fragments #1063
Test: noFetch with inline fragments #1063
Conversation
@TSMMark: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
@TSMMark what if you don't include Also, would this not be simpler if the second query was the same as the first? Is that not the issue you were seeing (component unmounted then remounted) |
I removed the If I remove
So I figured how to do that, and I had to change: const queryManager = mockQueryManager(
{
request: { query },
result: { data: data1 },
},
); to: const queryManager = createQueryManager({
networkInterface: mockNetworkInterface({
request: { query },
result: { data: data1 },
}),
addTypename: true,
}); Now, if I remove __typename from everywhere: const query = gql`
query query {
luke: people_one(id: 1) {
name
... on jedi {
age
}
}
}
`;
const data1 = {
luke: {
name: 'Luke Skywalker',
age: 50,
},
};
const queryManager = createQueryManager({
networkInterface: mockNetworkInterface({
request: { query },
result: { data: data1 },
}),
addTypename: true,
}); Then I get this error:
Which leads me to believe I need to add |
Oh, you should try making the fragment an interface rather than a concrete type like |
Hey, I think I got it. |
What happens now? Anything more I can do? |
@TSMMark I think this is a bit of a tough issue to solve (se #771). I think there is a future plan to fetch information from the server about the schema to make these decisions but without that or changes to the graphql spec ( |
@tmeasday Shucks. I guess in our app we will have to make some changes to the way we are querying our data because we really need this query to cache properly. Do you have any recommendations on a different way to architect this query so that the query manager will recognize when the data already exists on the client? Server and/or client modifications are all feasible. |
@TSMMark actually this reproduction isn't quite right as the expectation is incorrect. If you change it to assert.equal(result.data.allPeople.length, 2);
assert.equal(result.data.allPeople[0].name, 'Luke Skywalker');
assert.equal(result.data.allPeople[0].age, 50); The test passes as is. However if you remove the So in the So to be totally clear, my understanding of why this is happening is that when AC is matching It makes sense that I'm not sure what the best workaround would be, but one approach would be to implement your own cache checking logic by first querying with |
We're now keeping track of this and related issues on #1337 |
Original issue apollographql/react-apollo#336
@tmeasday @helfer I could not create a failing test here, but here is a passing one.