graphql-codegen-faker-fixtures
Version:
Generate faker fixtures for your fields
63 lines (59 loc) • 1.99 kB
TypeScript
import { CodegenConfig as CodegenConfig$1 } from '@graphql-codegen/cli';
import { PluginFunction } from '@graphql-codegen/plugin-helpers';
type ScalarsConfig = Partial<Record<string, Record<string, string> & {
_default?: string;
}>>;
declare const caseTypes: readonly ["camelCase", "capitalCase", "constantCase", "dotCase", "headerCase", "noCase", "paramCase", "pascalCase", "pathCase", "sentenceCase", "snakeCase"];
type CaseType = (typeof caseTypes)[number];
/**
* Config is being set through the config property in codegen.yml
*/
type PluginConfig = {
/**
* When true: plugin returns the builders-only, and skips disclaimer, utils, etc.
* Very useful when (unit-)testing this plugin
*/
buildersOnly?: boolean;
/**
* Choose a custom seed to use in `faker.seed()`
* Default: 12345654321
*/
fakerjsSeed?: number;
namingConvention?: "keep" | `change-case-all#${CaseType}`;
/**
* Override fields with custom faker methods?
*/
scalars?: ScalarsConfig;
/**
* Should we skip any fields? Notation is like: `VariantFragment.deliveryMethods`
*/
skipFields?: string[];
/**
* Should we skip whole fragments? Notation is like: deliveryMethodInfo
*/
skipFragments?: string[];
/**
* Where do we import the types from?
*/
typeImport?: string;
};
type CodegenConfig = CodegenConfig$1 & {
generates: {
[outputpath: string]: CodegenConfig$1["generates"][string] & {
config: PluginConfig;
};
};
};
type Plugin = PluginFunction<PluginConfig>;
/**
* The entry-point called from graphql-codegen
*
* This plugin works in three steps:
*
* 1. Collect all data-types on all fields defined in graphql Types/Interfaces
* 2. Collect all fields defined in Fragments, and map them against the collected fields in step-1.
* 3. Write typescript based on gathered info in step 2.
*
*/
declare const plugin: Plugin;
export { CodegenConfig, plugin };