Mike-Gibson / mock-apollo-client

Helps unit test components which use the Apollo Client.
MIT License
117 stars 15 forks source link

Handle queries which contain fragments in v1 #31

Closed Mike-Gibson closed 3 years ago

metreniuk commented 3 years ago

@Mike-Gibson Hi, I was trying to test queries with fragments and it failed with weird behaviour. Can you share more context so I can help integrate it?

Mike-Gibson commented 3 years ago

Hi @metreniuk, thanks for the question, and apologies for the empty description!

I created this issue as a reminder for me to port the changes made in #24 over to the newer version of mock apollo client. I just checked and I have some changes locally for this but I can't quite remember where I got to - it might actually be very close to being done, I think I just got distracted by other things!

I guess this is something that's blocking you from using mock-apollo-client? I'll try and take a look through the state of it tomorrow. I've pushed the changes to a new branch in the meantime. Seems like the tests pass. Feel free to give it a go and see if it's working on your project (fragments-1.x) - no worries if you'd rather wait for me to go over it though.

metreniuk commented 3 years ago

Thanks for the quick response! I think a can't use the github version because it is not builded. Can you push it to npm if it's not a problem?

Mike-Gibson commented 3 years ago

No problem - you'd have to have pulled it, built it locally and then used npm link to use the local dependency (a lot of effort!)

I've just merged the PR and published v1.2.0 of mock-apollo-client which should handle fragments. Please take a look and let me know if you have any issues.

metreniuk commented 3 years ago

It worked 👍 By the way __typename is needed even when the fragment is not union related. Thanks for the work you are doing!