Quick Example
This example will show how to:
- Create a Resolver Map with Resolver functions
- Apply a Resolver Wrapper to Resolver functions, the Sinon Spy Wrapper
spyWrapper(via@graphql-mocks/sinon) by usingembed. The spy wrapper will capture all calls to our resolver function which can be useful for testing. - Setup a GraphQL Handler with the the Resolver Wrapper to be able to execute queries
- Execute a Query with the GraphQL Handler
- Check the state object for the results of the Sinon Spies
[object Promise]```
First console.log
{
"data": {
"helloWorld": "Hello from our test resolver!"
}
}
Second console.log
"Hello from our test resolver!"
And that's an end-to-end example using the library to create a quick mock GraphQL API with the Sinon Spy Wrapper for introspection. Use the existing out-of-the-box Resolver Wrapper and Resolver Map Middlewares for even more functionality, or create your own.