@graphql-codegen/client-preset
Version:
GraphQL Code Generator preset for client.
75 lines (74 loc) • 2.65 kB
TypeScript
import type { Types } from '@graphql-codegen/plugin-helpers';
import { DocumentNode } from 'graphql';
export { default as babelOptimizerPlugin } from './babel.js';
export declare type FragmentMaskingConfig = {
/** @description Name of the function that should be used for unmasking a masked fragment property.
* @default `'useFragment'`
*/
unmaskFunctionName?: string;
};
export declare type ClientPresetConfig = {
/**
* @description Fragment masking hides data from components and only allows accessing the data by using a unmasking function.
* @exampleMarkdown
* ```tsx
* const config = {
* schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
* documents: ['src/**\/*.tsx', '!src\/gql/**\/*'],
* generates: {
* './src/gql/': {
* preset: 'client',
* presetConfig: {
* fragmentMasking: false,
* }
* },
* },
* };
* export default config;
* ```
*/
fragmentMasking?: FragmentMaskingConfig | boolean;
/**
* @description Specify the name of the "graphql tag" function to use
* @default "graphql"
*
* E.g. `graphql` or `gql`.
*
* @exampleMarkdown
* ```tsx
* const config = {
* schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
* documents: ['src/**\/*.tsx', '!src\/gql/**\/*'],
* generates: {
* './src/gql/': {
* preset: 'client',
* presetConfig: {
* gqlTagName: 'gql',
* }
* },
* },
* };
* export default config;
* ```
*/
gqlTagName?: string;
/**
* Generate metadata for a executable document node and embed it in the emitted code.
*/
onExecutableDocumentNode?: (documentNode: DocumentNode) => void | Record<string, unknown>;
/** Persisted operations configuration. */
persistedDocuments?: boolean | {
/**
* @description Behavior for the output file.
* @default 'embedHashInDocument'
* "embedHashInDocument" will add a property within the `DocumentNode` with the hash of the operation.
* "replaceDocumentWithHash" will fully drop the document definition.
*/
mode?: 'embedHashInDocument' | 'replaceDocumentWithHash';
/**
* @description Name of the property that will be added to the `DocumentNode` with the hash of the operation.
*/
hashPropertyName?: string;
};
};
export declare const preset: Types.OutputPreset<ClientPresetConfig>;