graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

Mocking best practice

Open tomchipchase opened this issue 7 years ago • 0 comments

I was wondering if anyone had any suggestions for mocking responses, and validating that the mock data matches the schema?

I'm modifying some code that calls a deprecated query to use a newer query (the data is the same, but it adds pagination, so the structure is slightly different).

I've followed the suggestions here: https://github.com/github/graphql-client/issues/33, specifically this: https://gist.github.com/joffotron/dde047f4158fce3bdbe615484c96377f

The issue I have is I have modified the request to use the newer query, without modifying my mock response. I would like my tests to fail because the current response isn't in a valid format for the new response, but its still passing. Is there a way I can validate my mock json structure against the response I'm expecting back in the query?

tomchipchase avatar Dec 12 '18 11:12 tomchipchase