import { QueryNode, VariableQueryNode } from '../../query-tree'; import { CollectFieldConfig } from '../config'; import { Field } from './field'; import { MessageLocation, ValidationContext } from '../validation'; import { RelationSide } from './relation'; import { RootEntityType } from './root-entity-type'; import { ObjectType, Type } from './type'; interface PathSegmentBase { readonly kind: 'field' | 'relation' | 'collect'; readonly field: Field; readonly resultingType: Type; readonly isListSegment: boolean; readonly resultIsList: boolean; readonly isNullableSegment: boolean; readonly resultIsNullable: boolean; /** * If true, the result can contain an entity multiple times. This e.g. happens when following a m-to-n relation. */ readonly resultMayContainDuplicateEntities: boolean; location?: MessageLocation; } export interface FieldSegment extends PathSegmentBase { readonly kind: 'field'; } export interface RelationSegment extends PathSegmentBase { readonly kind: 'relation'; readonly relationSide: RelationSide; readonly resultingType: RootEntityType; readonly minDepth: number; readonly maxDepth: number; /** * Will be evaluated on all vertices on the path, even those eliminated by minDepth */ readonly vertexFilter?: QueryNode; readonly vertexFilterVariable?: VariableQueryNode; } export interface CollectSegment extends PathSegmentBase { readonly kind: 'collect'; readonly path: CollectPath; } export type CollectPathSegment = FieldSegment | RelationSegment | CollectSegment; export declare class CollectPath { readonly declaringType: ObjectType; readonly path: string; private readonly astNode; constructor(config: CollectFieldConfig, declaringType: ObjectType); get segments(): ReadonlyArray; getFlatSegments(): ReadonlyArray; get resultingType(): Type | undefined; get resultIsList(): boolean; get resultIsNullable(): boolean; /** * If true, the result can contain the same item multiple times. This e.g. happens when following a m-to-n relation. */ get resultMayContainDuplicateEntities(): boolean; get traversesRootEntityTypes(): boolean; /** * @return true if valid, false if invalid */ validate(context: ValidationContext): boolean; private traversePath; } export declare function getEffectiveCollectSegments(path: CollectPath): { readonly relationSegments: ReadonlyArray; readonly fieldSegments: ReadonlyArray; }; export {};