Stylianos Gakis
05/04/2022, 3:19 PMMapTestNetworkTransport
instead. So I was wondering, since I don’t think there’s a way to do that right now, would it make sense to introduce a way to map an Operation to a result using something similar to registerTestResponse but by accepting an operation no matter what the inputs?
Otherwise the annoying part is that I have to in cases like the one I linked above, go inside the Activity and check what is being passed inside those queries and copy it inside the tests. But in the tests that I am doing right now I am mostly interested in how the UI reacts to a particular response, not that I am also sending the correct query.
With all that said, I know that the queue approach also exists, which doesn’t care for what the query was, but simply responds with specific things in order, but in many of these tests I do want the mapping functionality of at least the Operation type to the response, just not interested in what the input to that Operation was.
Does my idea make sense? Does it sound reasonable? Would it even be feasible? Should I reconsider the approach I’m taking maybe? If you have any sort of input I’d love to hear it.bod
05/04/2022, 3:28 PMStylianos Gakis
05/04/2022, 3:31 PMbod
05/04/2022, 3:33 PMNetworkTransport
very similar to MapTestNetworkTransport
but using ::class
in there for the keys of the map.bod
05/04/2022, 3:34 PMStylianos Gakis
05/04/2022, 3:36 PMbod
05/04/2022, 3:38 PMStylianos Gakis
05/05/2022, 2:53 PMOperation
too, since the ApolloResponse
requires an instance of an operation in its Builder function.
bod
05/05/2022, 4:09 PMtheI forgot about that 😅 Your solution looks good to me! Yes it's a bit 'hacky' to have the dummy operation, but it works 🙂requires an instance of an operation in its Builder function.ApolloResponse
bod
05/05/2022, 4:11 PMregisterMapTestResponse<LaunchDetailsQuery>
instead of passing the ::class
. But not even sure it's actually better/clearer of an API.Stylianos Gakis
05/05/2022, 9:11 PMStylianos Gakis
05/06/2022, 7:18 AMbod
05/06/2022, 9:22 AMI could try and contribute it if yesYes I think it would be cool to have it! The only tricky part I think is naming 😅 . Since the existing one is called
MapTestNetworkTransport
which would also match what the new one does.
Thinking out loud: maybe it would be possible to keep one MapTestNetworkTransport
that does both? Keep 2 maps, one for instances, one for classes, and in execute
try the instances one first, then fallback to the classes one?bod
05/06/2022, 9:23 AMwhy is it that the response keeps a reference to the OperationI think it's just a convenience thing 🙂 Looking at our code, it is not really used specifically.
Stylianos Gakis
05/06/2022, 9:27 AMbod
05/06/2022, 9:27 AMStylianos Gakis
05/06/2022, 9:28 AM