GraphQL Code Generator plugin for generating mock results for GraphQL operations based on your documents and schema. Current stable version is 1.0.8. It integrates with the GraphQL Codegen ecosystem, supports both JavaScript and TypeScript output, and requires peer dependency graphql (multiple versions supported). Key differentiators: automatically generates realistic mock data for queries and mutations, supports custom scalars, configurable naming conventions, and adds __typename when needed. It works seamlessly with @graphql-codegen/typescript and @graphql-codegen/typescript-operations for typed mocks.
npm install graphql-codegen-mock-resultsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows a complete setup: installation, codegen config with TypeScript and mock plugin, a sample query, and the generated mock output with __typename.
Include a `documents` path pointing to your .graphql files or GraphQL operations.
Add 'typescript' and 'typescript-operations' to the plugins list before 'graphql-codegen-mock-results'.
Add `customScalarValues: { Date: '2024-01-01', JSON: '{}' }` to plugin configuration.Ensure your project's graphql version is within the supported range. For graphql v16+, this plugin may not be compatible.
Run npm install -D graphql-codegen-mock-results
Ensure the plugin is installed in your project root. Run npm install -D graphql-codegen-mock-results from the project root.
Add a `documents` entry in your codegen.yml pointing to your GraphQL operations.