UNPKG

1.86 kBTypeScriptView Raw
1import { DocumentNode, FieldNode } from 'graphql';
2import { Reference, StoreObject, StoreValue, isReference } from '../../../utilities';
3import { StorageType } from '../../inmemory/policies';
4export declare type SafeReadonly<T> = T extends object ? Readonly<T> : T;
5export declare type MissingTree = string | {
6 readonly [key: string]: MissingTree;
7};
8export declare class MissingFieldError {
9 readonly message: string;
10 readonly path: MissingTree | Array<string | number>;
11 readonly query: DocumentNode;
12 readonly variables?: Record<string, any> | undefined;
13 constructor(message: string, path: MissingTree | Array<string | number>, query: DocumentNode, variables?: Record<string, any> | undefined);
14}
15export interface FieldSpecifier {
16 typename?: string;
17 fieldName: string;
18 field?: FieldNode;
19 args?: Record<string, any>;
20 variables?: Record<string, any>;
21}
22export interface ReadFieldOptions extends FieldSpecifier {
23 from?: StoreObject | Reference;
24}
25export interface ReadFieldFunction {
26 <V = StoreValue>(options: ReadFieldOptions): SafeReadonly<V> | undefined;
27 <V = StoreValue>(fieldName: string, from?: StoreObject | Reference): SafeReadonly<V> | undefined;
28}
29export declare type ToReferenceFunction = (objOrIdOrRef: StoreObject | string | Reference, mergeIntoStore?: boolean) => Reference | undefined;
30export declare type CanReadFunction = (value: StoreValue) => boolean;
31export declare type Modifier<T> = (value: T, details: {
32 DELETE: any;
33 INVALIDATE: any;
34 fieldName: string;
35 storeFieldName: string;
36 readField: ReadFieldFunction;
37 canRead: CanReadFunction;
38 isReference: typeof isReference;
39 toReference: ToReferenceFunction;
40 storage: StorageType;
41}) => T;
42export declare type Modifiers = {
43 [fieldName: string]: Modifier<any>;
44};
45//# sourceMappingURL=common.d.ts.map
\No newline at end of file