Skip to main content
Dev · 283 tools

Mock GraphQL Mutation Generator

Generates realistic fake GraphQL mutation strings for testing GraphQL APIs and clients

Generated GraphQL MutationsExample — click Generate for yours
mutation TestAddContact { addContact(input: { fullName: "Felix Park" email: "mei.larsen46@example.net" company: "Kestrel Robotics" phone: "+1-555-0156" }) { id createdAt } } --- mutation CreateCategory { createCategory(parentId: "cat_76hzhdg2", input: { name: "Kids" slug: "coastal-cutting-board-37" }) { id createdAt } } --- mutation CreatePatient { createPatient(input: { fullName: "Zoe Mensah" dateOfBirth: "1962-12-07" phone: "+1-555-0112" email: "ines.carter77@example.org" }) { id createdAt } }

Generated 60 words · 586 characters

See 3 examples
  • Example 1
    mutation TestAddContact {
      addContact(input: {
        fullName: "Felix Park"
        email: "mei.larsen46@example.net"
        company: "Kestrel Robotics"
        phone: "+1-555-0156"
      }) {
        id
        createdAt
      }
    }
    
    ---
    
    mutation CreateCategory {
      createCategory(parentId: "cat_76hzhdg2", input: {
        name: "Kids"
        slug: "coastal-cutting-board-37"
      }) {
        id
        createdAt
      }
    }
    
    ---
    
    mutation CreatePatient {
      createPatient(input: {
        fullName: "Zoe Mensah"
        dateOfBirth: "1962-12-07"
        phone: "+1-555-0112"
        email: "ines.carter77@example.org"
      }) {
        id
        createdAt
      }
    }
  • Example 2
    mutation TestCreateShipment {
      createShipment(input: {
        orderId: "ord_yxev98kr"
        carrierTrackingCode: "F4H-9447"
        destination: "4811 Maple Ave"
      }) {
        id
        createdAt
      }
    }
    
    ---
    
    mutation TestCreateLead {
      createLead(input: {
        name: "Omar Carter"
        email: "maya.novak13@example.com"
        company: "Bluebird Studio"
        source: "trade-show"
      }) {
        id
        createdAt
      }
    }
    
    ---
    
    mutation SubmitExpense {
      submitExpense(input: {
        amountCents: 230583
        merchant: "Orchard & Vine"
        incurredOn: "2026-03-22"
        note: "Arrived on time and well packed."
      }) {
        id
        createdAt
      }
    }
  • Example 3
    mutation AddVehicleMutation {
      addVehicle(ownerId: "usr_xzh42b2k", input: {
        plateNumber: "7JU-2933"
        color: "#132f90"
        odometerMiles: 227218
      }) {
        id
        createdAt
      }
    }
    
    ---
    
    mutation CreateTicket {
      createTicket(input: {
        subject: "Load testing plan"
        description: "Works as described, setup took five minutes."
        requesterEmail: "omar.haddad6@example.com"
        tags: ["backend", "design", "ops"]
      }) {
        id
        createdAt
      }
    }
    
    ---
    
    mutation AddComment {
      addComment(postId: "pst_uzp4t92y", input: {
        authorId: "usr_gbkftd8t"
        body: "Batch two will ship after inventory arrives."
      }) {
        id
        createdAt
      }
    }

About this generator

Writing GraphQL mutation strings by hand for every test case is repetitive: mutation keyword, named operation, input argument with realistic values, and a selection set on the return value. Miss any one and the mutation is malformed. A mock GraphQL mutation generator automates this for 52 resource types — users, orders, invoices, tickets, appointments, shipments, webhooks and more — across five operation categories. The `mutationType` input controls what gets generated. 'create' mutations use a resource-appropriate verb (createProduct, placeOrder, bookAppointment, uploadFile) with an input object of typed fields — names, emails, prices, dates, ISO timestamps, tag lists, and prefixed reference IDs — returning id and createdAt; child resources often take their parent ID as a separate argument. 'update' mutations pass a prefixed ID plus a partial input of one or two fields, returning id and updatedAt. 'delete' mutations use delete or a domain verb such as cancel, archive, revoke, or refund, take an ID, and return success, message, and deletedId. 'auth' mutations cover 24 account flows — login, sign-up, token refresh, logout, password reset, email verification, two-factor, API keys, magic links, and invitations. 'mixed' combines all four types randomly. All emails use reserved example domains and phone numbers use the fictional 555-01xx range.

How to use

  1. Select a mutation type from the dropdown — choose create, update, delete, or an authentication operation like login.
  2. Set the count field to how many distinct mutation strings you want generated in one batch.
  3. Click Generate to produce the mutation documents and review them in the output panel.
  4. Copy any mutation you want to use and paste it into GraphQL Playground, your test file, or your API client.
  5. Adjust field names and variable types to match your actual schema before running against a live endpoint.

Use Cases

  • •Seeding Apollo Client unit tests with realistic create and update mutation fixtures
  • •Populating GraphQL Playground with working demo operations during team onboarding
  • •Generating auth mutations like login and signup for MockedProvider security test cases
  • •Producing delete mutation batches to stress-test cascading resolver logic in staging
  • •Creating tutorial code samples for a Substack or course without writing GraphQL boilerplate

Tips

  • →Generate update and delete mutations together when testing resolver chains — IDs in delete mutations often depend on update responses.
  • →Use the authentication mutation type to get login and signup templates; these include token fields that are tedious to write from scratch.
  • →If your schema uses custom scalar types like DateTime or UUID, find them in the generated output and swap the placeholder types before executing.
  • →Generate a batch of five or more create mutations and compare the field variation — useful for spotting which optional fields your resolver actually needs.
  • →Paste a generated mutation into the Apollo Client Devtools query editor to test cache behavior without writing a full React component first.
  • →When writing MSW (Mock Service Worker) handlers for GraphQL, use the operation names from generated mutations to match requests by name rather than by body.

FAQ

how do I use generated mutations in apollo client tests

Copy the mutation string, wrap it with gql from @apollo/client, then pass it to MockedProvider's mocks array alongside a matching variables object and mock response. The generated mutations give you a realistic structure covering field names and variable patterns, so you only need to align them with your actual schema before wiring into tests.

are the generated mutations valid graphql syntax

Yes — each mutation uses correct GraphQL syntax: the mutation keyword, a named operation, arguments with string, number, boolean, enum, and list values, and a selection set on the return value. They parse without errors in any spec-compliant tool. They will not execute against a real schema unless that schema defines matching operation names, input types, and return fields.

what is the difference between the mutation types in this generator

Create mutations send an input object with two to five fields that fit the resource (a product gets name, SKU, price, and stock; an appointment gets a patient ID, start time, and duration). Update mutations pass a prefixed ID plus one or two changed fields. Delete mutations accept only an ID — using verbs like delete, archive, cancel, or revoke — and return a success flag. Auth mutations cover login, sign-up, token refresh, logout, password reset, two-factor, API keys, and similar flows with credential inputs and token-shaped return values. Mixed mode combines all four types randomly in a single batch.

can I use these mutation strings in graphql playground or apollo studio

Yes — paste any generated mutation directly into GraphQL Playground's operation editor or Apollo Studio's sandbox. If your schema defines a matching operation, it will execute. If not, you will see a validation error showing which field names need to be aligned. This makes generated mutations useful for prototyping: paste, observe the validation errors, and use them as a guide for what your schema needs to define.

You might also like

Popular tools from other categories that share themes with this one.