UNPKG

2.29 kBTypeScriptView Raw
1import { ClientSideBaseVisitor, ClientSideBasePluginConfig, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
2import { ReactApolloRawPluginConfig } from './config';
3import { OperationDefinitionNode, GraphQLSchema } from 'graphql';
4import { Types } from '@graphql-codegen/plugin-helpers';
5export interface ReactApolloPluginConfig extends ClientSideBasePluginConfig {
6 withComponent: boolean;
7 withHOC: boolean;
8 withHooks: boolean;
9 withMutationFn: boolean;
10 withRefetchFn: boolean;
11 apolloReactCommonImportFrom: string;
12 apolloReactComponentsImportFrom: string;
13 apolloReactHocImportFrom: string;
14 apolloReactHooksImportFrom: string;
15 componentSuffix: string;
16 reactApolloVersion: 2 | 3;
17 withResultType: boolean;
18 withMutationOptionsType: boolean;
19 addDocBlocks: boolean;
20 defaultBaseOptions: {
21 [key: string]: string;
22 };
23 hooksSuffix: string;
24}
25export declare class ReactApolloVisitor extends ClientSideBaseVisitor<ReactApolloRawPluginConfig, ReactApolloPluginConfig> {
26 protected rawConfig: ReactApolloRawPluginConfig;
27 private _externalImportPrefix;
28 private imports;
29 constructor(schema: GraphQLSchema, fragments: LoadedFragment[], rawConfig: ReactApolloRawPluginConfig, documents: Types.DocumentFile[]);
30 private getImportStatement;
31 private getReactImport;
32 private getApolloReactCommonIdentifier;
33 private getApolloReactHooksIdentifier;
34 private usesExternalHooksOnly;
35 private getApolloReactCommonImport;
36 private getApolloReactComponentsImport;
37 private getApolloReactHocImport;
38 private getApolloReactHooksImport;
39 private getOmitDeclaration;
40 private getDefaultOptions;
41 private getDocumentNodeVariable;
42 getImports(): string[];
43 private _buildHocProps;
44 private _buildMutationFn;
45 private _buildOperationHoc;
46 private _buildComponent;
47 private _buildHooksJSDoc;
48 private _buildHooks;
49 private _getHookSuffix;
50 private _buildResultType;
51 private _buildWithMutationOptionsType;
52 private _buildRefetchFn;
53 protected buildOperation(node: OperationDefinitionNode, documentVariableName: string, operationType: string, operationResultType: string, operationVariablesTypes: string, hasRequiredVariables: boolean): string;
54}