Dev
Dummy GraphQL Variables Generator
Testing GraphQL APIs without realistic variable payloads is slow, error-prone work. This dummy GraphQL variables generator produces properly structured JSON objects for five common operations — createUser, updateUser, deleteItem, getProduct, and createOrder — so you can skip the manual JSON crafting and get straight to testing. Each output includes realistic fake data: UUID-format IDs, plausible names and emails, nested arrays, and typed fields that match what a real API would expect. Paste the generated variables directly into the Variables panel of GraphQL Playground, drop them into Postman or Insomnia request bodies, or use them as fixtures in Jest or Vitest integration tests. Because the data is structurally correct for each operation type, you're testing against payloads that actually resemble production traffic, not toy examples you typed by hand. The generator supports batch output, so you can create multiple variable objects in a single click. This is especially useful when you need to seed a test database, populate mock API handlers in tools like MSW, or generate a range of inputs to check edge-case handling in resolvers. Whether you're writing a new mutation and need a quick sanity check, or building a test suite that requires dozens of distinct fixtures, the tool removes the friction of constructing valid GraphQL variable JSON from scratch.
How to Use
- Select an operation type from the dropdown — createUser, updateUser, deleteItem, getProduct, or createOrder.
- Set the count field to how many distinct variable objects you need in a single batch.
- Click Generate to produce the JSON output in the results panel below.
- Copy one object or the full array, then paste it into the Variables panel of your API client or save it as a test fixture file.
Use Cases
- •Populating GraphQL Playground Variables panel during resolver development
- •Generating fixtures for Jest integration tests against a live GraphQL endpoint
- •Creating sample payloads for GraphQL API documentation and README examples
- •Seeding a test database via createUser and createOrder mutations repeatedly
- •Mocking request bodies in Postman collections for CI pipeline testing
- •Supplying realistic data to MSW (Mock Service Worker) GraphQL handlers
- •Validating input type validation and error handling in custom resolvers
- •Bulk-generating updateUser payloads to load-test a GraphQL subscriptions server
Tips
- →Generate 5-10 createUser objects at once, then use them as seeds in a beforeAll() block to populate a test database before running query tests.
- →For deleteItem and updateUser operations, copy an ID from a createUser result first so your test chain uses consistent, referentially valid identifiers.
- →Combine multiple operation types in one test file: generate createOrder variables to insert records, then use getProduct variables to verify reads — covering a full CRUD cycle.
- →When documenting an API, generate one object per operation and include them in your README or Notion doc as 'example variables' so consumers can copy-paste immediately.
- →If your resolver enforces strict UUID validation, the generated UUIDs will pass it — but swap in a malformed ID manually in one test case to confirm your error handling fires correctly.
- →Use the batch output with MSW's graphql.mutation handler: map the array into separate handler responses to simulate different server states in Storybook or component tests.
FAQ
What are GraphQL variables?
GraphQL variables are JSON objects sent alongside a query or mutation to supply dynamic input values. Instead of hardcoding arguments directly in the operation string, you define variables with a $ prefix in the query signature and pass their values separately. This keeps operations reusable, improves security by preventing injection, and makes it easier for clients to parameterize requests.
How do I use generated variables in GraphQL Playground?
Copy the generated JSON object, then open the Variables panel at the bottom of GraphQL Playground (the tab labeled 'Query Variables'). Paste the JSON there. In your query or mutation, declare matching variable names with the $ prefix — for example, $input: CreateUserInput! — and Playground will bind the values automatically when you run the operation.
How do I use GraphQL variables in Postman?
In Postman, set the request body to raw JSON. The body should be an object with two keys: 'query' containing your GraphQL operation string, and 'variables' containing the JSON object from this generator. Postman sends both to the endpoint together. You can also use Postman's GraphQL body type, which has a dedicated Variables field for the same purpose.
Why use fake variable data instead of writing it manually?
Hand-typed test data tends to be repetitive and unrealistic — e.g., 'test@test.com' or id: '1'. Realistic fake data with UUIDs, proper name formats, and nested structures catches more bugs: type mismatches, ID format validation, and nested resolver logic that simple placeholder values would never trigger.
Can I use these variables with Apollo Client devtools?
Yes. Apollo Client devtools lets you run operations manually from the browser panel. You can paste the generated variable JSON into the variables input field there. It's useful for testing mutations against your live frontend app's Apollo instance without writing a temporary UI form or hitting the endpoint directly.
What does the createOrder operation output include?
The createOrder variable object includes fields like a UUID order ID, a customer ID, an array of line items each with productId and quantity, a shipping address object, and a payment method string. This nested structure lets you test resolvers that traverse relationships and validate complex input types rather than flat scalar fields.
How do I use multiple generated objects as test fixtures?
Set the count input to the number you need, then generate. Copy the full output array and save it as a .json file or a JS array in a __fixtures__ directory. In Jest or Vitest, import the file and loop over the array with test.each() to run the same assertion against every generated payload automatically.
Are the generated IDs in a real UUID format?
Yes. Generated ID fields follow the standard UUID v4 format (e.g., 'a3f2c1d4-5e6b-7890-abcd-ef1234567890'), which means they'll pass UUID validation middleware and format checks that many GraphQL APIs apply. Using sequential integers like 1, 2, 3 would skip that validation layer entirely.