Description
Is your feature request related to a problem? Please describe.
See detailed description of the problem at https://stackoverflow.com/questions/79634678/graphql-tools-mock-does-not-produce-randomized-response-on-repeated-gql-requests.
Describe the solution you'd like
Currently the official doc on mocking does not provide guidance on how the mock store can be reset upon each request.
// Fill this in with the schema string
const schemaString = `...`
// Make a GraphQL schema with no resolvers
const schema = makeExecutableSchema({ typeDefs: schemaString })
// Create a new schema with mocks
const schemaWithMocks = addMocksToSchema({ schema })
In scenarios where a developer needs refreshed data response upon each new request towards the mock server, currently the only solution seems to be creating a mock store ahead of time, and add an HTTP request interceptor to reset the mock store. It would be nicer this can be exposed to the addMocksToSchema
interface like below. And implementation of the mock store is revised accordingly to support that.
const schemaWithMocks = addMocksToSchema({ schema, resetMockStore: true });
Or if there is any other better alternative for clients to configure this, that will be even greater.
Describe alternatives you've considered
See a workaround in the answer of the same SO post.