@graphql-codegen/plugin-helpers
- Version 5.1.0
- Published
- 116 kB
- 6 dependencies
- MIT license
Install
npm i @graphql-codegen/plugin-helpers
yarn add @graphql-codegen/plugin-helpers
pnpm add @graphql-codegen/plugin-helpers
Overview
GraphQL Code Generator common utils and types
Index
Variables
Functions
- addFederationReferencesToSchema()
- checkObjectTypeFederationDetails()
- createNoopProfiler()
- createProfiler()
- getBaseType()
- hasNullableTypeRecursively()
- isComplexPluginOutput()
- isConfiguredOutput()
- isOutputConfigArray()
- isUsingTypes()
- isWrapperType()
- mergeOutputs()
- normalizeConfig()
- normalizeInstanceOrArray()
- normalizeOutputParam()
- oldVisit()
- removeFederation()
- removeNonNullWrapper()
- resolveExternalModuleAndFn()
Classes
Interfaces
Type Aliases
Namespaces
Types
- ApolloEngineSchemaOptions
- ComplexPluginOutput
- Config
- ConfiguredDocumentTransform
- ConfiguredOutput
- ConfiguredPlugin
- CustomDocumentLoader
- CustomDocumentLoaderOptions
- DocumentFile
- DocumentTransformFile
- DocumentTransformFileConfig
- DocumentTransformFileName
- DocumentTransformFunction
- DocumentTransformObject
- FileOutput
- GenerateOptions
- GitHubSchemaOptions
- HookAlterFunction
- HookFunction
- InstanceOrArray
- LifeCycleAlterHookValue
- LifecycleHooksDefinition
- LifeCycleHookValue
- LocalSchemaPathOptions
- LocalSchemaPathWithOptions
- NamedPlugin
- NamedPreset
- OperationDocument
- OperationDocumentGlobPath
- OutputConfig
- OutputDocumentTransform
- OutputPreset
- PackageLoaderFn
- PluginConfig
- PluginOutput
- PresetFnArgs
- PresetNames
- PresetNamesBase
- Promisable
- RequireExtension
- Schema
- SchemaFromCodeFile
- SchemaFromCodeFileOptions
- SchemaGlobPath
- SchemaWithLoader
- SchemaWithLoaderOptions
- SkipDocumentsValidationOptions
- UrlSchemaOptions
- UrlSchemaWithOptions
Variables
variable federationSpec
const federationSpec: any;
Federation Spec
variable getCachedDocumentNodeFromSchema
const getCachedDocumentNodeFromSchema: any;
Functions
function addFederationReferencesToSchema
addFederationReferencesToSchema: (schema: GraphQLSchema) => GraphQLSchema;
Adds
__resolveReference
in each ObjectType involved in Federation.Parameter schema
function checkObjectTypeFederationDetails
checkObjectTypeFederationDetails: ( node: ObjectTypeDefinitionNode | GraphQLObjectType, schema: GraphQLSchema) => { resolvableKeyDirectives: readonly DirectiveNode[] } | false;
Checks if Object Type is involved in Federation. Based on
@key
directiveParameter node
Type
function createNoopProfiler
createNoopProfiler: () => Profiler;
function createProfiler
createProfiler: () => Profiler;
function getBaseType
getBaseType: (type: GraphQLOutputType) => GraphQLNamedType;
function hasNullableTypeRecursively
hasNullableTypeRecursively: (type: GraphQLOutputType) => boolean;
function isComplexPluginOutput
isComplexPluginOutput: ( obj: Types.PluginOutput) => obj is Types.ComplexPluginOutput<Record<string, unknown>>;
function isConfiguredOutput
isConfiguredOutput: (type: any) => type is Types.ConfiguredOutput;
function isOutputConfigArray
isOutputConfigArray: (type: any) => type is Types.OutputConfig[];
function isUsingTypes
isUsingTypes: ( document: DocumentNode, externalFragments: string[], schema?: GraphQLSchema) => boolean;
function isWrapperType
isWrapperType: (t: GraphQLOutputType) => t is any;
function mergeOutputs
mergeOutputs: ( content: Types.PluginOutput | Array<Types.PluginOutput>) => string;
function normalizeConfig
normalizeConfig: ( config: Types.OutputConfig | Types.OutputConfig[]) => Types.ConfiguredPlugin[];
function normalizeInstanceOrArray
normalizeInstanceOrArray: <T>(type: T | T[]) => T[];
function normalizeOutputParam
normalizeOutputParam: ( config: Types.OutputConfig | Types.ConfiguredPlugin[] | Types.ConfiguredOutput) => Types.ConfiguredOutput;
function oldVisit
oldVisit: ( root: ASTNode, { enter: enterVisitors, leave: leaveVisitors, ...newVisitor }: OldVisitor) => any;
function removeFederation
removeFederation: (schema: GraphQLSchema) => GraphQLSchema;
Removes Federation Spec from GraphQL Schema
Parameter schema
Parameter config
function removeNonNullWrapper
removeNonNullWrapper: (type: GraphQLOutputType) => GraphQLOutputType;
function resolveExternalModuleAndFn
resolveExternalModuleAndFn: (pointer: any) => any;
Classes
class ApolloFederation
class ApolloFederation {}
constructor
constructor({ enabled, schema }: { enabled: boolean; schema: GraphQLSchema });
property meta
protected meta: { [typename: string]: TypeMeta };
method filterFieldNames
filterFieldNames: (fieldNames: string[]) => string[];
Excludes
__resolveReference
fieldsParameter fieldNames
List of field names
method filterTypeNames
filterTypeNames: (typeNames: string[]) => string[];
Excludes types definde by Federation
Parameter typeNames
List of type names
method getMeta
getMeta: () => { [typename: string]: TypeMeta };
method isResolveReferenceField
isResolveReferenceField: (fieldNode: FieldDefinitionNode) => boolean;
method setMeta
setMeta: (typename: string, update: Partial<TypeMeta>) => void;
method skipDirective
skipDirective: (name: string) => boolean;
Decides if directive should not be generated
Parameter name
directive's name
method skipField
skipField: ({ fieldNode, parentType,}: { fieldNode: FieldDefinitionNode; parentType: GraphQLNamedType;}) => boolean;
Decides if field should not be generated
Parameter data
method skipScalar
skipScalar: (name: string) => boolean;
Decides if scalar should not be generated
Parameter name
directive's name
method transformParentType
transformParentType: ({ fieldNode, parentType, parentTypeSignature,}: { fieldNode: FieldDefinitionNode; parentType: GraphQLNamedType; parentTypeSignature: string;}) => string;
Transforms ParentType signature in ObjectTypes involved in Federation
Parameter data
Interfaces
interface CodegenPlugin
interface CodegenPlugin<T = any> {}
property addToSchema
addToSchema?: AddToSchemaResult | ((config: T) => AddToSchemaResult);
property plugin
plugin: PluginFunction<T>;
property validate
validate?: PluginValidateFn;
interface Profiler
interface Profiler {}
interface ProfilerEvent
interface ProfilerEvent {}
property args
args?: any;
Any arguments provided for the event. Some of the event types have required argument fields, otherwise, you can put any information you wish in here. The arguments are displayed in Trace Viewer when you view an event in the analysis section.
property cat
cat: string;
The event categories. This is a comma separated list of categories for the event. The categories can be used to hide events in the Trace Viewer UI.
property cname
cname?: string;
A fixed color name to associate with the event. If provided, cname must be one of the names listed in trace-viewer's base color scheme's reserved color names list
property dur
dur: number;
duration
property name
name: string;
The name of the event, as displayed in Trace Viewer
property ph
ph: string;
The event type. This is a single character which changes depending on the type of event being output. The valid values are listed in the table below. We will discuss each phase type below.
property pid
pid: number;
The process ID for the process that output this event.
property tid
tid: number;
The thread ID for the thread that output this event.
property ts
ts: number;
The tracing clock timestamp of the event. The timestamps are provided at microsecond granularity.
property tts
tts?: string;
Optional. The thread clock timestamp of the event. The timestamps are provided at microsecond granularity.
Type Aliases
type AddToSchemaResult
type AddToSchemaResult = string | DocumentNode | undefined;
type PluginFunction
type PluginFunction< T = any, TOutput extends Types.PluginOutput = Types.PluginOutput> = ( schema: GraphQLSchema, documents: Types.DocumentFile[], config: T, info?: { outputFile?: string; allPlugins?: Types.ConfiguredPlugin[]; pluginContext?: { [key: string]: any; }; [key: string]: any; }) => Types.Promisable<TOutput>;
type PluginValidateFn
type PluginValidateFn<T = any> = ( schema: GraphQLSchema, documents: Types.DocumentFile[], config: T, outputFile: string, allPlugins: Types.ConfiguredPlugin[], pluginContext?: { [key: string]: any; }) => Types.Promisable<void>;
Namespaces
namespace Types
namespace Types {}
interface ApolloEngineSchemaOptions
interface ApolloEngineSchemaOptions {}
property 'apollo-engine'
'apollo-engine': ApolloEngineOptions;
interface Config
interface Config {}
Represents the root YAML schema for the config file. false
property config
config?: PluginConfig;
object true Configuration object containing key => value that will be passes to the plugins. Specifying configuration in this level of your configuration file will pass it to all plugins, in all outputs.
The options may vary depends on what plugins you are using.
For more details: https://graphql-code-generator.com/docs/config-reference/config-field
property customFetch
customFetch?: string;
Name for a library that implements
fetch
. Use this to tell codegen to use that to fetch schemas in a custom way.
property debug
debug?: boolean;
A flag to output debug logs
property documents
documents?: InstanceOrArray<OperationDocument>;
A pointer(s) to your GraphQL documents: query, mutation, subscription and fragment. These documents will be loaded into for all your output files. You can use one of the following:
- Path to a local
.graphql
file - Path to a code file (for example:.js
or.tsx
) containing GraphQL operation strings. - Glob expression pointing to multiple.graphql
files - Glob expression pointing to multiple code files - Inline string containing GraphQL SDL operation definitionYou can specify either a single file, or multiple.
For more details: https://graphql-code-generator.com/docs/config-reference/documents-field
property emitLegacyCommonJSImports
emitLegacyCommonJSImports?: boolean;
A flag to disable adding
.js
extension to the output file. Default:true
.
property errorsOnly
errorsOnly?: boolean;
A flag to print only errors.
property generates
generates: { [outputPath: string]: ConfiguredOutput | ConfiguredPlugin[];};
A map where the key represents an output path for the generated code and the value represents a set of options which are relevant for that specific file.
For more details: https://graphql-code-generator.com/docs/config-reference/codegen-config
property hooks
hooks?: Partial<LifecycleHooksDefinition>;
Specifies scripts to run when events are happening in the codegen core. Hooks defined on that level will effect all output files.
For more details: https://graphql-code-generator.com/docs/config-reference/lifecycle-hooks
property ignoreNoDocuments
ignoreNoDocuments?: boolean;
A flag to suppress non-zero exit code when there are no documents to generate.
property noSilentErrors
noSilentErrors?: boolean;
Alows to raise errors if any matched files are not valid GraphQL. Default: false.
property overwrite
overwrite?: boolean;
A flag to overwrite files if they already exist when generating code (
true
by default).For more details: https://graphql-code-generator.com/docs/config-reference/codegen-config
property pluckConfig
pluckConfig?: { /** * @description An array of package name and identifier that will be used to track down your gql usages and imports. Use this if your code files imports gql from another library or you have a custom gql tag. identifier is the named export, so don't provide it if the tag function is imported as default. */ modules?: Array<{ /** * @description the name of the NPM package name you wish to look for */ name: string; /** * @description the tag identifier name you wish to look for */ identifier?: string; }>; /** * @description Configures the magic GraphQL comments to look for. The default is `GraphQL`. */ gqlMagicComment?: string; /** * @description Overrides the name of the default GraphQL name identifier. */ globalIdentifier?: string; /** * @description Allows to use a global identifier instead of a module import. */ globalGqlIdentifierName?: string | string[];};
Allows you to override the configuration for
@graphql-tools/graphql-tag-pluck
, the tool that extracts your GraphQL operations from your code files.For more details: https://graphql-code-generator.com/docs/config-reference/documents-field#graphql-tag-pluck
property pluginContext
pluginContext?: { [key: string]: any;};
Additional context passed to plugins
property pluginLoader
pluginLoader?: PackageLoaderFn<CodegenPlugin>;
If you are using the programmatic API in a browser environment, you can override this configuration to load your plugins in a way different than require.
property require
require?: RequireExtension;
A path to a file which defines custom Node.JS require() handlers for custom file extensions. This is essential if the code generator has to go through files which require other files in an unsupported format (by default).
For more details: https://graphql-code-generator.com/docs/config-reference/require-field See more information about require.extensions: https://gist.github.com/jamestalmage/df922691475cff66c7e6.
Note: values that specified in your .yml file will get loaded after loading the config .yml file.
property schema
schema?: InstanceOrArray<Schema>;
A pointer(s) to your GraphQL schema. This schema will be the base schema for all your outputs. You can use one of the following:
- URL pointing to a GraphQL endpoint - Path to a local
.json
file - Path to a local.graphql
file - Glob expression pointing to multiple.graphql
files - Path to a local code file (for example:.js
) that exportsGraphQLSchema
object - Inline string containing GraphQL SDL schema definitionYou can specify either a single schema, or multiple, and GraphQL Code Generator will merge the schemas into a single schema.
For more details: https://graphql-code-generator.com/docs/config-reference/schema-field
property silent
silent?: boolean;
A flag to suppress printing errors when they occur.
property verbose
verbose?: boolean;
A flag to output more detailed information about tasks
property watch
watch?: boolean | string | string[];
A flag to trigger codegen when there are changes in the specified GraphQL schemas.
You can either specify a boolean to turn it on/off or specify an array of glob patterns to add custom files to the watch.
For more details: https://graphql-code-generator.com/docs/getting-started/development-workflow#watch-mode
property watchConfig
watchConfig?: { usePolling: boolean; interval?: number;};
Deprecated
this is not necessary since we are using
@parcel/watcher
instead ofchockidar
.Allows overriding the behavior of watch to use stat polling over native file watching support.
Config fields have the same defaults and sematics as the identically named ones for chokidar.
For more details: https://graphql-code-generator.com/docs/getting-started/development-workflow#watch-mode
interface ConfiguredOutput
interface ConfiguredOutput {}
false
property config
config?: PluginConfig;
Configuration object containing key => value that will be passes to the plugins. Specifying configuration in this level of your configuration file will pass it to all plugins, in all outputs.
The options may vary depends on what plugins you are using.
For more details: https://graphql-code-generator.com/docs/config-reference/config-field
property documents
documents?: InstanceOrArray<OperationDocument>;
A pointer(s) to your GraphQL documents: query, mutation, subscription and fragment. These documents will be loaded into for all your output files. You can use one of the following:
- Path to a local
.graphql
file - Path to a code file (for example:.js
or.tsx
) containing GraphQL operation strings. - Glob expression pointing to multiple.graphql
files - Glob expression pointing to multiple code files - Inline string containing GraphQL SDL operation definitionYou can specify either a single file, or multiple.
For more details: https://graphql-code-generator.com/docs/config-reference/documents-field
property documentTransforms
documentTransforms?: OutputDocumentTransform[];
DocumentTransform changes documents before executing plugins.
property hooks
hooks?: Partial<LifecycleHooksDefinition>;
Specifies scripts to run when events are happening in the codegen core. Hooks defined on that level will effect only the current output files.
For more details: https://graphql-code-generator.com/docs/config-reference/lifecycle-hooks
property overwrite
overwrite?: boolean;
A flag to overwrite files if they already exist when generating code (
true
by default).For more details: https://graphql-code-generator.com/docs/config-reference/codegen-config
property plugins
plugins?: OutputConfig[];
array { "$ref": "#/definitions/GeneratedPluginsMap" } List of plugins to apply to this current output file.
You can either specify plugins from the community using the NPM package name (after you installed it in your project), or you can use a path to a local file for custom plugins.
You can find a list of available plugins here: https://the-guild.dev/graphql/codegen/docs/plugins/index Need a custom plugin? read this: https://the-guild.dev/graphql/codegen/docs/custom-codegen/index
property preset
preset?: PresetNames | OutputPreset;
If your setup uses Preset to have a more dynamic setup and output, set the name of your preset here.
Presets are a way to have more than one file output, for example: https://the-guild.dev/graphql/codegen/docs/presets/near-operation-file
You can either specify a preset from the community using the NPM package name (after you installed it in your project), or you can use a path to a local file for a custom preset.
List of available presets: https://graphql-code-generator.com/docs/presets/presets-index
property presetConfig
presetConfig?: { [key: string]: any;};
If your setup uses Preset to have a more dynamic setup and output, set the configuration object of your preset here.
List of available presets: https://graphql-code-generator.com/docs/presets/presets-index
property schema
schema?: InstanceOrArray<Schema>;
A pointer(s) to your GraphQL schema. This schema will be available only for this specific
generates
record. You can use one of the following:- URL pointing to a GraphQL endpoint - Path to a local
.json
file - Path to a local.graphql
file - Glob expression pointing to multiple.graphql
files - Path to a local code file (for example:.js
) that exportsGraphQLSchema
object - Inline string containing GraphQL SDL schema definitionYou can specify either a single schema, or multiple, and GraphQL Code Generator will merge the schemas into a single schema.
For more details: https://graphql-code-generator.com/docs/config-reference/schema-field
property watchPattern
watchPattern?: string | string[];
@description: Additional file pattern to watch when using watch mode
interface ConfiguredPlugin
interface ConfiguredPlugin {}
index signature
[name: string]: PluginConfig;
interface CustomDocumentLoader
interface CustomDocumentLoader {}
index signature
[path: string]: CustomDocumentLoaderOptions;
interface CustomDocumentLoaderOptions
interface CustomDocumentLoaderOptions {}
false Specify a path to a custom loader for your GraphQL documents.
property loader
loader: string;
Specify a path to a custom code file (local or module) that will handle the documents loading.
interface DocumentFile
interface DocumentFile extends Source {}
property hash
hash?: string;
interface GenerateOptions
interface GenerateOptions {}
property config
config: { [key: string]: any;};
property documents
documents: Types.DocumentFile[];
property documentTransforms
documentTransforms?: ConfiguredDocumentTransform[];
property filename
filename: string;
property pluginContext
pluginContext?: { [key: string]: any;};
property pluginMap
pluginMap: { [name: string]: CodegenPlugin;};
property plugins
plugins: Types.ConfiguredPlugin[];
property profiler
profiler?: Profiler;
property schema
schema: DocumentNode;
property schemaAst
schemaAst?: GraphQLSchema;
property skipDocumentsValidation
skipDocumentsValidation?: Types.SkipDocumentsValidationOptions;
method cache
cache: <T>( namespace: string, key: string, factory: () => Promise<T>) => Promise<T>;
interface GitHubSchemaOptions
interface GitHubSchemaOptions {}
index signature
[githubProtocol: string]: { token: string;};
interface LocalSchemaPathOptions
interface LocalSchemaPathOptions {}
false Loads a schema a local file or files, with customized options for parsing/loading.
property allowLegacySDLEmptyFields
allowLegacySDLEmptyFields?: boolean;
If enabled, the parser will parse empty fields sets in the Schema Definition Language. Otherwise, the parser will follow the current specification.
This option is provided to ease adoption of the final SDL specification and will be removed in v16.
false
property allowLegacySDLImplementsInterfaces
allowLegacySDLImplementsInterfaces?: boolean;
If enabled, the parser will parse implemented interfaces with no
&
character between each interface. Otherwise, the parser will follow the current specification.This option is provided to ease adoption of the final SDL specification and will be removed in v16.
false
property assumeValidSDL
assumeValidSDL?: boolean;
Set to true to assume the SDL is valid.
false
property commentDescriptions
commentDescriptions?: boolean;
Converts all GraphQL comments (
#
sign) to descriptions during the parse phase, to make it available for plugins later. false
property experimentalFragmentVariables
experimentalFragmentVariables?: boolean;
EXPERIMENTAL:
If enabled, the parser will understand and parse variable definitions contained in a fragment definition. They'll be represented in the
variableDefinitions
field of the FragmentDefinitionNode.The syntax is identical to normal, query-defined variables. For example:
fragment A($var: Boolean = false) on T { ... }
Note: this feature is experimental and may change or be removed in the future.
false
property noLocation
noLocation?: boolean;
By default, the parser creates AST nodes that know the location in the source that they correspond to. This configuration flag disables that behavior for performance or testing.
false
property skipGraphQLImport
skipGraphQLImport?: boolean;
Skips checks for graphql-import syntax and loads the file as-is, without imports support. true
interface LocalSchemaPathWithOptions
interface LocalSchemaPathWithOptions {}
index signature
[globPath: string]: LocalSchemaPathOptions;
interface SchemaFromCodeFile
interface SchemaFromCodeFile {}
index signature
[path: string]: SchemaFromCodeFileOptions;
interface SchemaFromCodeFileOptions
interface SchemaFromCodeFileOptions {}
false Loads schema using a pointer, without using
require
while looking for schemas in code files.
property assumeValid
assumeValid?: boolean;
Set this to
true
in order to tell codegen to skip documents validation.
property noPluck
noPluck?: boolean;
Set this to
true
in order to tell codegen not to try to extract GraphQL AST strings schema/docs
property noRequire
noRequire?: boolean;
Set this to
true
in order to tell codegen not to try torequire
files in order to find schema/docs
interface SchemaWithLoader
interface SchemaWithLoader {}
index signature
[pointer: string]: SchemaWithLoaderOptions;
interface SchemaWithLoaderOptions
interface SchemaWithLoaderOptions {}
false Loads schema using a pointer, with a custom loader (code file).
property loader
loader: string;
Specify a path to a custom code file (local or module) that will handle the schema loading.
interface UrlSchemaOptions
interface UrlSchemaOptions {}
false Loads a schema from remote endpoint, with custom http options.
property customFetch
customFetch?: string;
Specify a Node module name, or a custom file, to be used instead of standard
fetch
property handleAsSDL
handleAsSDL?: boolean;
Handling the response as SDL will allow you to load schema from remote server that doesn't return a JSON introspection.
property headers
headers?: { [headerName: string]: string;};
HTTP headers you wish to add to the HTTP request sent by codegen to fetch your GraphQL remote schema.
property method
method?: string;
HTTP Method to use, either POST (default) or GET.
interface UrlSchemaWithOptions
interface UrlSchemaWithOptions {}
index signature
[url: string]: UrlSchemaOptions;
type ComplexPluginOutput
type ComplexPluginOutput<M = Record<string, unknown>> = { content: string; prepend?: string[]; append?: string[]; meta?: M;};
type ConfiguredDocumentTransform
type ConfiguredDocumentTransform<T = object> = { name: string; transformObject: DocumentTransformObject<T>; config?: T;};
type DocumentTransformFile
type DocumentTransformFile<T> = | DocumentTransformFileName | DocumentTransformFileConfig<T>;
type DocumentTransformFileConfig
type DocumentTransformFileConfig<T = object> = { [name: DocumentTransformFileName]: T;};
type DocumentTransformFileName
type DocumentTransformFileName = string;
type DocumentTransformFunction
type DocumentTransformFunction<Config = object> = (options: { documents: Types.DocumentFile[]; schema: DocumentNode; config: Config; pluginContext?: { [key: string]: any; };}) => Types.Promisable<Types.DocumentFile[]>;
type DocumentTransformObject
type DocumentTransformObject<T = object> = { transform: DocumentTransformFunction<T>;};
type FileOutput
type FileOutput = { filename: string; content: string; hooks?: { beforeOneFileWrite?: LifecycleHooksDefinition['beforeOneFileWrite']; afterOneFileWrite?: LifecycleHooksDefinition['afterOneFileWrite']; };};
type HookAlterFunction
type HookAlterFunction = (...args: any[]) => void | string | Promise<void | string>;
type HookFunction
type HookFunction = (...args: any[]) => void | Promise<void>;
type InstanceOrArray
type InstanceOrArray<T> = T | T[];
type LifeCycleAlterHookValue
type LifeCycleAlterHookValue = | string | HookFunction | HookAlterFunction | (string | HookFunction | HookAlterFunction)[];
type LifecycleHooksDefinition
type LifecycleHooksDefinition = { /** * @description Triggered with no arguments when the codegen starts (after the `codegen.yml` has beed parsed). * * Specify a shell command to run. */ afterStart: LifeCycleHookValue; /** * @description Triggered with no arguments, right before the codegen closes, or when watch mode is stopped. * * Specify a shell command to run. */ beforeDone: LifeCycleHookValue; /** * @description Triggered every time a file changes when using watch mode. * Triggered with two arguments: the type of the event (for example, `changed`) and the path of the file. */ onWatchTriggered: LifeCycleHookValue; /** * @description Triggered in case of a general error in the codegen. The argument is a string containing the error. */ onError: LifeCycleHookValue; /** * @description Triggered after a file is written to the file-system. Executed with the path for the file. * If the content of the file hasn't changed since last execution - this hooks won't be triggered. * * > This is a very useful hook, you can use it for integration with Prettier or other linters. */ afterOneFileWrite: LifeCycleHookValue; /** * @description Executed after writing all the files to the file-system. * Triggered with multiple arguments - paths for all files. */ afterAllFileWrite: LifeCycleHookValue; /** * @description Triggered before a file is written to the file-system. * Executed with the path and content for the file. * * Returning a string will override the content of the file. * * If the content of the file hasn't changed since last execution - this hooks won't be triggered. */ beforeOneFileWrite: LifeCycleAlterHookValue; /** * @description Executed after the codegen has done creating the output and before writing the files to the file-system. * * Triggered with multiple arguments - paths for all relevant files. * * > Not all the files will be actually written to the file-system, because this is triggered before checking if the file has changed since last execution. */ beforeAllFileWrite: LifeCycleHookValue;};
All available lifecycle hooks false
type LifeCycleHookValue
type LifeCycleHookValue = string | HookFunction | (string | HookFunction)[];
type NamedPlugin
type NamedPlugin = string;
type NamedPreset
type NamedPreset = string;
type OperationDocument
type OperationDocument = OperationDocumentGlobPath | CustomDocumentLoader;
type OperationDocumentGlobPath
type OperationDocumentGlobPath = string;
type OutputConfig
type OutputConfig = NamedPlugin | ConfiguredPlugin;
type OutputDocumentTransform
type OutputDocumentTransform<T = object> = | DocumentTransformObject<T> | DocumentTransformFile<T>;
type OutputPreset
type OutputPreset<TPresetConfig = any> = { buildGeneratesSection: ( options: PresetFnArgs<TPresetConfig> ) => Promisable<GenerateOptions[]>; prepareDocuments?: ( outputFilePath: string, outputSpecificDocuments: Types.OperationDocument[] ) => Promisable<Types.OperationDocument[]>;};
type PackageLoaderFn
type PackageLoaderFn<TExpectedResult> = ( name: string) => Promisable<TExpectedResult>;
type PluginConfig
type PluginConfig<T = any> = { [key: string]: T;};
type PluginOutput
type PluginOutput = string | ComplexPluginOutput;
type PresetFnArgs
type PresetFnArgs< Config = any, PluginConfig = { [key: string]: any; }> = { presetConfig: Config; baseOutputDir: string; plugins: Types.ConfiguredPlugin[]; schema: DocumentNode; schemaAst?: GraphQLSchema; documents: Types.DocumentFile[]; config: PluginConfig; pluginMap: { [name: string]: CodegenPlugin; }; pluginContext?: { [name: string]: any; }; profiler?: Profiler; cache?<T>(namespace: string, key: string, factory: () => Promise<T>): Promise<T>; documentTransforms?: ConfiguredDocumentTransform[];};
type PresetNames
type PresetNames = `${PresetNamesBase}-preset` | PresetNamesBase;
type PresetNamesBase
type PresetNamesBase = | 'client' | 'near-operation-file' | 'gql-tag-operations' | 'graphql-modules' | 'import-types';
type Promisable
type Promisable<T> = T | Promise<T>;
type RequireExtension
type RequireExtension = InstanceOrArray<string>;
type Schema
type Schema = | string | UrlSchemaWithOptions | ApolloEngineSchemaOptions | GitHubSchemaOptions | LocalSchemaPathWithOptions | SchemaGlobPath | SchemaWithLoader | SchemaFromCodeFile;
A URL to your GraphQL endpoint, a local path to
.graphql
file, a glob pattern to your GraphQL schema files, or a JavaScript file that exports the schema to generate code from. This can also be an array which specifies multiple schemas to generate code from. You can read more about the supported formats [here](schema-field#available-formats).
type SchemaGlobPath
type SchemaGlobPath = string;
type SkipDocumentsValidationOptions
type SkipDocumentsValidationOptions = | { /** * @description Allows you to skip specific rules while validating the documents. * See all the rules; https://github.com/graphql/graphql-js/tree/main/src/validation/rules */ ignoreRules?: string[]; /** * @description Ignore duplicate documents validation */ skipDuplicateValidation?: boolean; /** * @description Skip document validation entirely against the schema */ skipValidationAgainstSchema?: boolean; } | boolean;
Package Files (9)
Dependencies (6)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (1)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@graphql-codegen/plugin-helpers
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@graphql-codegen/plugin-helpers)
- HTML<a href="https://www.jsdocs.io/package/@graphql-codegen/plugin-helpers"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4903 ms. - Missing or incorrect documentation? Open an issue for this package.