One of the key components to a stellar developer experience is GraphQL schema mocking.
Schema mocking allows developers to:
- Develop features faster by mocking unit tests with little to no code
- Simplify e2e testing by mocking the entire schema at the network level
- Test client data handling by intercepting and modifying server responses at the field level
- Visualize how your component will look in production by using mocked data directly in Storybook
At Coinbase, we have iterated over sophisticated schema mocking solutions over the last few years as we have migrated to GraphQL. We’ve had failures and successes, and lots of learning along the way.
In this talk, we’ll dive deep into the following topics:
- Out-Of-The-Box Tooling (Nock, MSW, Relay MockPayloadGenerator, graphql-tools/mock)
- Custom Helpers (Operation Mocking, Data Component Wrappers, Network Middleware)
- Client Side Data Manipulation (Mocking Single Fields, Client Schema Extensions)
- Storybook (Loading Live/Mocked Data, Update Field Mocks Dynamically)