UNPKG

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

Version:
72 lines (71 loc) 2.44 kB
import type { Types } from '@graphql-codegen/plugin-helpers'; import babelPlugin from './babel.cjs'; export declare 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 declare 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 * ```yaml {5} * generates: * gql/: * preset: gql-tag-operations-preset * presetConfig: * augmentedModuleName: '@urql/core' * ``` */ augmentedModuleName?: string; /** * @description Fragment masking hides data from components and only allows accessing the data by using a unmasking function. * @exampleMarkdown * ```yaml * generates: * gql/: * preset: gql-tag-operations-preset * presetConfig: * fragmentMasking: true * ``` * * 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 * ```yaml {6-7} * generates: * gql/: * preset: gql-tag-operations-preset * presetConfig: * augmentedModuleName: '@urql/core' * fragmentMasking: * augmentedModuleName: '@urql/fragment' * ``` */ fragmentMasking?: FragmentMaskingConfig | boolean; /** * @description Specify the name of the "graphql tag" function to use * @default "gql" * * E.g. `graphql` or `gql`. * * @exampleMarkdown * ```yaml {5} * generates: * gql/: * preset: gql-tag-operations-preset * presetConfig: * gqlTagName: 'graphql' * ``` */ gqlTagName?: string; }; export declare const preset: Types.OutputPreset<GqlTagConfig>; export { babelPlugin };