I’m looking for a way to run a query against a mock data object.
The problem
I currently mock the GQL response via <MockedProvider mocks={mocks}>
. That works great, but the mock’s result
comes back exactly as defined. The mock response can return fields the query did not ask for.
The request
I would like to have a fake data library and generate the mock result data by getting the fake data and “running” the query against it. Apollo iOS has pretty much what I want, but it’s not available for React + Typescript. For example:
const fakeUserData = {id: 1, name: "First Last"};
query = gql`query { user { id } }`;
query.data.from(fakeUserData):
// Returns: {id: 1} without `name`.
Does this exist somewhere? Does this pattern make sense?
Thanks!