A plugin for GraphQL Code Generator that automatically creates factory functions for your GraphQL types. Version 1.2.1 (stable) generates factories for all types defined in your schema, enabling easy test data creation with default values. Differentiates from similar tools by tight integration with graphql-codegen and zero-config setup. Released under MIT license.
npm install graphql-codegen-factoriesNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configure GraphQL Code Generator to use the factories plugin and generate factory functions from your schema. Then use them in tests to create data with custom overrides.
Manually specify enum fields when calling build() or wrap factory to provide defaults
Ensure your project supports ESM or TypeScript, or pin to 1.1.x
Move inline types to a .graphql schema file
Remove 'mocks' from codegen.yml and use 'factories' if you had custom mock settings
Run: npm install graphql-codegen-factories --save-dev
Use: import factoriesPlugin from 'graphql-codegen-factories'
Check file path and extension in codegen.yml