Home

MSW with GraphQL

Resources

  1. GraphQL API

tl;dr

The GraphQL call:

query AllCategories { allCategories { nodes { name } } }

The corelating code:

// src/mocks/handlers.js import { graphql } from "msw" export const handlers = [ graphql.query("AllCategories", (_req, res, ctx) => { return res( ctx.data({ allCategories: { nodes: [ { name: "Testing", }, ], }, }) ) }), ]

Repository

https://github.com/okeeffed/developer-notes-nextjs/content/mock-service-worker/msw-with-graphql

Sections


Related