@getcronit/pylon-builder
Version:
84 lines (83 loc) • 2.07 kB
TypeScript
import ts from 'typescript';
import { Union as _Union, Enum as _Enum } from './type-definition-builder.js';
type Union = _Union & {
description: string;
__resolveType?: (obj: any) => string;
};
type Interface = {
name: string;
description: string;
fields: Array<Field>;
__resolveType?: (obj: any) => string;
};
type Enum = _Enum & {
description: string;
};
interface TypeDefinition {
name: string;
isList: boolean;
isRequired: boolean;
description: string;
}
interface Field {
name: string;
type: TypeDefinition;
}
interface Input {
name: string;
description: string;
fields: Array<{
name: string;
type: TypeDefinition;
}>;
}
interface Type {
name: string;
description: string;
fields: Array<Field & {
args: Array<{
name: string;
type: TypeDefinition;
}>;
}>;
implements?: Array<string>;
rawType: ts.Type;
}
export interface Schema {
types: Array<Type>;
inputs: Array<Input>;
interfaces: Array<Interface>;
unions: Array<Union>;
enums: Array<Enum>;
scalars: Array<string>;
}
interface Index {
Query?: ts.Type;
Mutation?: ts.Type;
Subscription?: ts.Type;
}
export declare class SchemaParser {
private schema;
private checker;
private program;
private sfiFile;
private typeDefinitionBuilder;
constructor(checker: ts.TypeChecker, sfiFile: ts.SourceFile, program: ts.Program);
parse(index: Index): void;
private checkIfInterfaceIsPossibleForUnion;
private getResolveTypeForUnionOrInterface;
toString(): string;
getSchema(): Schema;
getResolvers(): Record<string, {
__resolveType?: (obj: any) => string;
}>;
private processSchemaReference;
private getSymbolDocumentation;
private getTypeDocumentation;
/**
* Extracts reserved field names from the schema by removing them from their respective types and inputs.
*/
private extractForbiddenFieldNamesFromSchema;
private makeReferenceSchema;
}
export {};