Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions src/execution/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ export interface FormattedExecutionResult<

export interface ExperimentalIncrementalExecutionResults<
TInitial = ObjMap<unknown>,
TSubsequent = unknown,
TData = ObjMap<unknown>,
TIncrementalItem = unknown,
TExtensions = ObjMap<unknown>,
> {
initialResult: InitialIncrementalExecutionResult<TInitial, TExtensions>;
subsequentResults: AsyncGenerator<
SubsequentIncrementalExecutionResult<TSubsequent, TExtensions>,
SubsequentIncrementalExecutionResult<TData, TIncrementalItem, TExtensions>,
void,
void
>;
Expand All @@ -68,23 +69,29 @@ export interface FormattedInitialIncrementalExecutionResult<
}

export interface SubsequentIncrementalExecutionResult<
TData = unknown,
TData = ObjMap<unknown>,
TIncrementalItem = unknown,
TExtensions = ObjMap<unknown>,
> {
pending?: ReadonlyArray<PendingResult>;
incremental?: ReadonlyArray<IncrementalResult<TData, TExtensions>>;
incremental?: ReadonlyArray<
IncrementalResult<TData, TIncrementalItem, TExtensions>
>;
completed?: ReadonlyArray<CompletedResult>;
hasNext: boolean;
extensions?: TExtensions;
}

export interface FormattedSubsequentIncrementalExecutionResult<
TData = unknown,
TData = ObjMap<unknown>,
TIncrementalItem = unknown,
TExtensions = ObjMap<unknown>,
> {
hasNext: boolean;
pending?: ReadonlyArray<PendingResult>;
incremental?: ReadonlyArray<FormattedIncrementalResult<TData, TExtensions>>;
incremental?: ReadonlyArray<
FormattedIncrementalResult<TData, TIncrementalItem, TExtensions>
>;
completed?: ReadonlyArray<FormattedCompletedResult>;
extensions?: TExtensions;
}
Expand Down Expand Up @@ -114,41 +121,46 @@ export interface FormattedIncrementalDeferResult<
extensions?: TExtensions;
}

interface StreamItemsRecordResult<TData = ReadonlyArray<unknown>> {
interface StreamItemsRecordResult<TIncrementalItem = unknown> {
errors?: ReadonlyArray<GraphQLError>;
items: TData;
items: ReadonlyArray<TIncrementalItem>;
}

export interface IncrementalStreamResult<
TData = ReadonlyArray<unknown>,
TIncrementalItem = unknown,
TExtensions = ObjMap<unknown>,
> extends StreamItemsRecordResult<TData> {
> extends StreamItemsRecordResult<TIncrementalItem> {
id: string;
subPath?: ReadonlyArray<string | number>;
extensions?: TExtensions;
}

export interface FormattedIncrementalStreamResult<
TData = Array<unknown>,
TIncrementalItem = unknown,
TExtensions = ObjMap<unknown>,
> {
errors?: ReadonlyArray<GraphQLFormattedError>;
items: TData;
items: ReadonlyArray<TIncrementalItem>;
id: string;
subPath?: ReadonlyArray<string | number>;
extensions?: TExtensions;
}

export type IncrementalResult<TData = unknown, TExtensions = ObjMap<unknown>> =
export type IncrementalResult<
TData = ObjMap<unknown>,
TIncrementalItem = unknown,
TExtensions = ObjMap<unknown>,
> =
| IncrementalDeferResult<TData, TExtensions>
| IncrementalStreamResult<TData, TExtensions>;
| IncrementalStreamResult<TIncrementalItem, TExtensions>;

export type FormattedIncrementalResult<
TData = unknown,
TData = ObjMap<unknown>,
TIncrementalItem = unknown,
TExtensions = ObjMap<unknown>,
> =
| FormattedIncrementalDeferResult<TData, TExtensions>
| FormattedIncrementalStreamResult<TData, TExtensions>;
| FormattedIncrementalStreamResult<TIncrementalItem, TExtensions>;

export interface PendingResult {
id: string;
Expand Down
Loading