Skip to main content
Dev · 283 tools

Fake GraphQL Query Generator

Generates realistic fake GraphQL queries and mutations for testing and documentation

Generated GraphQL OperationsExample — click Generate for yours
query GetUser($id: ID!) { user(id: $id) { id notificationSettings { email push } isActive plan role email } } # --- query ListUsers($first: Int, $after: String, $filter: UserFilter) { users(first: $first, after: $after, filter: $filter) { nodes { id notificationSettings { email push } isActive plan role email } totalCount pageInfo { hasNextPage endCursor } } } # --- mutation CreateUser($input: CreateUserInput!) { createUser(input: $input) { id notificationSettings { email push } isActive plan role email } } # --- mutation UpdateUser($id: ID!, $input: UpdateUserInput!) { updateUser(id: $id, input: $input) { id notificationSettings { email push } isActive plan role email } } # --- mutation DeleteUser($id: ID!) { deleteUser(id: $id) { success id } } # --- subscription OnUserUpdated($id: ID!) { userUpdated(id: $id) { id notificationSettings { email push } isActive plan role email } }

Generated 137 words · 1,184 characters

See 3 examples
  • Example 1
    query GetUser($id: ID!) {
      user(id: $id) {
        id
        notificationSettings {
          email
          push
        }
        isActive
        plan
        role
        email
      }
    }
    
    # ---
    
    query ListUsers($first: Int, $after: String, $filter: UserFilter) {
      users(first: $first, after: $after, filter: $filter) {
        nodes {
          id
          notificationSettings {
            email
            push
          }
          isActive
          plan
          role
          email
        }
        totalCount
        pageInfo {
          hasNextPage
          endCursor
        }
      }
    }
    
    # ---
    
    mutation CreateUser($input: CreateUserInput!) {
      createUser(input: $input) {
        id
        notificationSettings {
          email
          push
        }
        isActive
        plan
        role
        email
      }
    }
    
    # ---
    
    mutation UpdateUser($id: ID!, $input: UpdateUserInput!) {
      updateUser(id: $id, input: $input) {
        id
        notificationSettings {
          email
          push
        }
        isActive
        plan
        role
        email
      }
    }
    
    # ---
    
    mutation DeleteUser($id: ID!) {
      deleteUser(id: $id) {
        success
        id
      }
    }
    
    # ---
    
    subscription OnUserUpdated($id: ID!) {
      userUpdated(id: $id) {
        id
        notificationSettings {
          email
          push
        }
        isActive
        plan
        role
        email
      }
    }
  • Example 2
    query GetUser($id: ID!) {
      user(id: $id) {
        id
        twoFactorEnabled
        status
        address {
          city
          country
          postalCode
        }
        emailVerifiedAt
        preferences
      }
    }
    
    # ---
    
    query ListUsers($first: Int, $after: String, $filter: UserFilter) {
      users(first: $first, after: $after, filter: $filter) {
        nodes {
          id
          twoFactorEnabled
          status
          address {
            city
            country
            postalCode
          }
          emailVerifiedAt
          preferences
        }
        totalCount
        pageInfo {
          hasNextPage
          endCursor
        }
      }
    }
    
    # ---
    
    mutation CreateUser($input: CreateUserInput!) {
      createUser(input: $input) {
        id
        twoFactorEnabled
        status
        address {
          city
          country
          postalCode
        }
        emailVerifiedAt
        preferences
      }
    }
    
    # ---
    
    mutation UpdateUser($id: ID!, $input: UpdateUserInput!) {
      updateUser(id: $id, input: $input) {
        id
        twoFactorEnabled
        status
        address {
          city
          country
          postalCode
        }
        emailVerifiedAt
        preferences
      }
    }
    
    # ---
    
    mutation DeleteUser($id: ID!) {
      deleteUser(id: $id) {
        success
        id
      }
    }
    
    # ---
    
    subscription OnUserUpdated($id: ID!) {
      userUpdated(id: $id) {
        id
        twoFactorEnabled
        status
        address {
          city
          country
          postalCode
        }
        emailVerifiedAt
        preferences
      }
    }
  • Example 3
    query GetUser($id: ID!) {
      user(id: $id) {
        id
        timezone
        referralCode
        pronouns
        organization {
          id
          name
        }
        twoFactorEnabled
      }
    }
    
    # ---
    
    query ListUsers($first: Int, $after: String, $filter: UserFilter) {
      users(first: $first, after: $after, filter: $filter) {
        nodes {
          id
          timezone
          referralCode
          pronouns
          organization {
            id
            name
          }
          twoFactorEnabled
        }
        totalCount
        pageInfo {
          hasNextPage
          endCursor
        }
      }
    }
    
    # ---
    
    mutation CreateUser($input: CreateUserInput!) {
      createUser(input: $input) {
        id
        timezone
        referralCode
        pronouns
        organization {
          id
          name
        }
        twoFactorEnabled
      }
    }
    
    # ---
    
    mutation UpdateUser($id: ID!, $input: UpdateUserInput!) {
      updateUser(id: $id, input: $input) {
        id
        timezone
        referralCode
        pronouns
        organization {
          id
          name
        }
        twoFactorEnabled
      }
    }
    
    # ---
    
    mutation DeleteUser($id: ID!) {
      deleteUser(id: $id) {
        success
        id
      }
    }
    
    # ---
    
    subscription OnUserUpdated($id: ID!) {
      userUpdated(id: $id) {
        id
        timezone
        referralCode
        pronouns
        organization {
          id
          name
        }
        twoFactorEnabled
      }
    }

About this generator

Writing syntactically correct GraphQL operations by hand is tedious when you need them for mocking before a real schema exists. A fake GraphQL query generator produces valid operations for any resource name — following Relay-style cursor pagination, typed input variables on mutations, and WebSocket subscription syntax. Three inputs control the output. Resource/type name accepts any PascalCase string — User, Order, BlogPost — and the generator derives list query names (ListUsers), single-fetch names (GetUser), mutation names (CreateUser, UpdateUser, DeleteUser), and subscription names (OnUserUpdated) automatically. Operation type filters to query, mutation, subscription, or all three. Fields per type sets how many fields appear (2–15). Fields come from a pool matched to the resource name — user-like types get email, displayName and lastLoginAt; orders get totalAmount and lineItems; posts get title, author and publishedAt; tasks, events, media and products have their own sets, and anything else gets a generic set. Every selection starts with id, and some fields include nested selections such as author { id displayName }. The output is syntactically valid GraphQL, but treat it as a structural template and swap in the fields your schema defines.

How to use

  1. Type your GraphQL type name into the Resource field using PascalCase, such as "Product" or "OrderItem".
  2. Select an operation type from the dropdown: choose "all" for the full CRUD set, or pick a specific type like "mutation" to generate only those operations.
  3. Set the Fields per Type number to control selection set size — use 3–5 for lean test fixtures or 7–10 for documentation examples.
  4. Click Generate and review the output panel, which contains one complete GraphQL operation block per selected type.
  5. Copy the output and paste it into your .graphql file, test fixture, MSW handler, or GraphQL Playground tab.

Use Cases

  • •Generating MSW graphql.query() and graphql.mutation() handlers with realistic operation names like GetUser or UpdateOrder
  • •Scaffolding Jest or Vitest snapshot fixtures before a backend GraphQL schema is finalized
  • •Populating Insomnia or Postman GraphQL collections with sample operations for a new API resource
  • •Creating concrete query and mutation examples for API reference docs without needing a live schema
  • •Prototyping Apollo Client useQuery hooks in Storybook stories while the backend is still in development

Tips

  • →Set resource to match your exact type name — the generator uses it as the operation name prefix, so "BlogPost" produces GetBlogPost and CreateBlogPost, keeping output paste-ready.
  • →Use fieldCount of 3–4 when generating fixtures for unit tests; bloated selection sets make snapshot diffs noisy and harder to maintain.
  • →Generate the "all" operation type first to get the full picture, then re-run with a specific type selected to get a cleaner block for documentation or a single test file.
  • →The list query's first/after arguments, nodes array and pageInfo block are Relay-compatible — if you're using Apollo Client with a Relay-style cache policy, the pagination logic maps directly without modification.
  • →Combine multiple runs with different resource names to build a complete mock API layer: generate User, Post, and Comment operations separately, then assemble them into a single MSW handler file.
  • →If your schema uses snake_case field names rather than camelCase, do a quick find-and-replace on the output before committing — the generator always produces camelCase to match GraphQL convention.

FAQ

can I run generated GraphQL queries against my real API

Not directly — field names come from a pool matched to the kind of resource (users, products, orders, posts, events, tasks, media or a generic set) and won't match your schema exactly. Treat the output as a structural template: the syntax, variable declarations, operation names, and pagination patterns are all valid GraphQL, but you will need to swap in the field names your schema actually defines.

what is the difference between a query, mutation, and subscription

Queries fetch data without side effects. Mutations create, update, or delete records and return the affected object so clients can update their cache. Subscriptions open a persistent WebSocket connection and push updates when specified data changes — useful for real-time features like chat or live dashboards.

how does the field count setting affect the generated output

fieldCount controls how many fields appear in each operation's selection set. Setting it to 3–4 produces minimal queries ideal for unit test snapshots. Setting it to 8–12 generates richer examples better suited for documentation. List queries add a pageInfo block and totalCount on top of the selected fields.

are list queries paginated in the generated output

Yes. List queries use Relay-style cursor pagination with a nodes array, a totalCount field, and a pageInfo block containing hasNextPage and endCursor. This is compatible with Apollo Client's Relay-style cache policy without modification.

You might also like

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