This repository provides an example of using Mock Service Worker (MSW) with GraphQL. MSW is a powerful tool for mocking API requests in both development and testing environments.
- Node.js (>= 12.x)
-
Clone the repository:
git clone https://github.com/dalvarado86/msw-graphql-example.git cd msw-graphql-example -
Install dependencies:
npm install
Note: Latest version of MSW is having issues with Next.JS, please use the 2.0.14 in the meaintime MSW is fixed.
To start the development server:
npm run devThis example demonstrates how to set up MSW to intercept GraphQL requests and provide mock responses. You can customize the mocks in the src/mocks/handlers.js file.