UNPKG

@graphql-codegen/flutter-freezed

Version:

GraphQL Code Generator plugin to generate Freezed models from your GraphQL schema

28 lines (27 loc) 2.02 kB
import { EnumValueDefinitionNode } from 'graphql'; import { FieldName, TypeName } from '../config/pattern.js'; import { AppliesOn, DartIdentifierCasing, FieldType, FlutterFreezedPluginConfig, NodeType } from '../config/plugin-config.js'; import { NodeRepository } from './node-repository.js'; export declare class Block { static buildImportStatements: (fileName: string) => string; /** * Transforms the AST nodes into Freezed classes/models * @param config The plugin configuration object * @param node the AST node passed by the schema visitor * @param nodeRepository A map that stores the name of the Graphql Type as the key and it AST node as the value. Used to build FactoryBlocks from placeholders for mergedInputs and Union Types * @returns a string output of a `FreezedDeclarationBlock` which represents a Freezed class/model in Dart */ static build: (config: FlutterFreezedPluginConfig, node: NodeType, nodeRepository: NodeRepository) => string; static buildComment: (node?: NodeType | FieldType | EnumValueDefinitionNode) => string; static buildBlockName: (config: FlutterFreezedPluginConfig, blockAppliesOn: readonly AppliesOn[], identifier: string, typeName: TypeName, fieldName?: FieldName, blockCasing?: DartIdentifierCasing) => string; static tokens: { defaultFactory: string; unionFactory: string; mergedFactory: string; fromJsonToJson: string; }; static regexpForToken: (tokenName: 'defaultFactory' | 'unionFactory' | 'mergedFactory' | 'fromJsonToJson') => RegExp; static replaceTokens: (config: FlutterFreezedPluginConfig, nodeRepository: NodeRepository, generatedBlocks: string[]) => string; static replaceDefaultFactoryToken: (block: string, config: FlutterFreezedPluginConfig, nodeRepository: NodeRepository) => string; static replaceNamedFactoryToken: (block: string, config: FlutterFreezedPluginConfig, nodeRepository: NodeRepository, blockType: 'unionFactory' | 'mergedFactory') => string; }