UNPKG

@graphql-codegen/gql-tag-operations-preset

Version:
108 lines (107 loc) 3.52 kB
import type { Types } from '@graphql-codegen/plugin-helpers'; export { default as babelPlugin } from './babel.js'; export type FragmentMaskingConfig = { /** * @description The module name from which a augmented module should be imported from. */ augmentedModuleName?: string; /** @description Name of the function that should be used for unmasking a masked fragment property. * @default `'useFragment'` */ unmaskFunctionName?: string; }; export type GqlTagConfig = { /** * @description Instead of generating a `gql` function, this preset can also generate a `d.ts` that will enhance the `gql` function of your framework. * * E.g. `graphql-tag` or `@urql/core`. * * @exampleMarkdown * ```ts filename="codegen.ts" {10} * import type { CodegenConfig } from '@graphql-codegen/cli'; * * const config: CodegenConfig = { * // ... * generates: { * 'path/to/file.ts': { * preset: 'gql-tag-operations', * presetConfig: { * augmentedModuleName: '@urql/core' * }, * }, * }, * }; * export default config; * ``` */ augmentedModuleName?: string; /** * @description Fragment masking hides data from components and only allows accessing the data by using a unmasking function. * @exampleMarkdown * ```ts filename="codegen.ts" {10} * import type { CodegenConfig } from '@graphql-codegen/cli'; * * const config: CodegenConfig = { * // ... * generates: { * 'path/to/file.ts': { * preset: 'gql-tag-operations', * presetConfig: { * fragmentMasking: true * }, * }, * }, * }; * export default config; * ``` * * When using the `augmentedModuleName` option, the unmask function will by default NOT be imported from the same module. It will still be generated to a `index.ts` file. You can, however, specify to resolve the unmasking function from an an augmented module by using the `augmentedModuleName` object sub-config. * @exampleMarkdown * ```ts filename="codegen.ts" {10-13} * import type { CodegenConfig } from '@graphql-codegen/cli'; * * const config: CodegenConfig = { * // ... * generates: { * 'path/to/file.ts': { * preset: 'gql-tag-operations', * presetConfig: { * augmentedModuleName: '@urql/core', * fragmentMasking: { * augmentedModuleName: '@urql/fragment', * }, * }, * }, * }, * }; * export default config; * ``` */ fragmentMasking?: FragmentMaskingConfig | boolean; /** * @description Specify the name of the "graphql tag" function to use * @default "gql" * * E.g. `graphql` or `gql`. * * @exampleMarkdown * ```ts filename="codegen.ts" {10} * import type { CodegenConfig } from '@graphql-codegen/cli'; * * const config: CodegenConfig = { * // ... * generates: { * 'path/to/file.ts': { * preset: 'gql-tag-operations', * presetConfig: { * gqlTagName: 'graphql' * }, * }, * }, * }; * export default config; * ``` */ gqlTagName?: string; }; export declare const preset: Types.OutputPreset<GqlTagConfig>;