apollographql / apollo-feature-requests

🧑‍🚀 Apollo Client Feature Requests | (no 🐛 please).
Other
130 stars 7 forks source link

Add `MockedResponse` -> `newData` to docs #205

Open wild-lotus opened 4 years ago

wild-lotus commented 4 years ago

I just realised that when providing a MockedResponse to MockedProvider, you can provide a newData key in the MockedResponse. This seems to be an alternative to the result key. I have found no documentation about it.

My request here is to add this newData to MockedProvider docs.

On top of that, if you could leave here a brief explanation of the differences between newData and result for the meantime, I would appreciate.

stuartjbrown commented 2 years ago

I'd also like some info about this newData - could you find something out @CarlosGines ? Or can someone else give more info? Thanks!

artium-ryanh commented 1 year ago

I've seen this addition requested here and on other websites and people have been requesting it for years. I just want to say it's super inconvenient that it hasn't been added to the docs yet. So far, all I can gather about newData is that it's a function run to get maybe data for successive calls but not the first one? I have no idea how it's different from result being a function.

bignimbus commented 1 year ago

Hi @artium-ryanh @stuartjbrown @CarlosGines 👋🏻 newData lets users control the mocked response result dynamically in case they want to test scenarios with responses that can't be statically defined. Here's an SO thread showing a real-world usage. And here's a blog post by @jkettmann that goes into some depth about how they used newData for mutation testing. I agree this should be in the docs - not sure when the maintainers will get to it but I hope this info is enough to go on for now. And if you're interested in submitting a PR we'd definitely be interested in reviewing it!

artium-ryanh commented 1 year ago

@bignimbus It does help, thank you! I was able to figure that out with experimentation and I'm glad to know this post can be a resource for people searching for the same thing I was. I'd consider drafting a PR, but I'm not sure where I would make it. Can you link me to the docs repo?

bignimbus commented 1 year ago

@artium-ryanh awesome 🚀 I think this file would probably be a good place to start: https://github.com/apollographql/apollo-client/blob/main/docs/source/development-testing/testing.mdx