Open wild-lotus opened 4 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!
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.
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!
@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?
@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
I just realised that when providing a
MockedResponse
toMockedProvider
, you can provide anewData
key in theMockedResponse
. This seems to be an alternative to theresult
key. I have found no documentation about it.My request here is to add this
newData
toMockedProvider
docs.On top of that, if you could leave here a brief explanation of the differences between
newData
andresult
for the meantime, I would appreciate.