We have a test suite which in 2.x relied on mocking a map of requests to responses using their string representations of how the query looked like (QUERY_DOCUMENT before, OPERATION_DOCUMENT now) mapped to their Operation.Data. This can be seen
here for example.
Before, this was mapped to json
here using some MergingResponseWriter and as you can see it also uses the marshaler which both are things I can’t directly use in 3.x so I have been trying to simply look for alternatives.
So I’m trying to make it work while not changing how all the tests are written, so I am met with trying to go from Operation.Data -> json representation without having an instance of the Operation, in order to take that json response and put it inside the MockServer as the return value
Now I’ve also looked into using the new testing capabilities from the library which I thought were very interesting, and I did try to make it work as shown
here (I might still look into this later after we at least got the app running while using Apollo 3.x) but it turns out we are doing some tests
without even using the generated code from apollo and the tests were doing some tricks to handle queries that take parameters and have those be part of the response by manually
extracting them here, and providing them to the response
here.
So I’ve just been trying to make it all work while still keeping the same test API basically and this has not been easy during this migration since we’re doing a lot of “weird” stuff I guess 😄 And I am like certain there’s probably stuff that could be simplified if we re-wrote this whole thing, but I am trying to at least try to get it work first so that I have the confidence to do some bigger changes.