UNPKG

1.91 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 extends Error {
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 readonly missing: MissingTree;
15}
16export interface FieldSpecifier {
17 typename?: string;
18 fieldName: string;
19 field?: FieldNode;
20 args?: Record<string, any>;
21 variables?: Record<string, any>;
22}
23export interface ReadFieldOptions extends FieldSpecifier {
24 from?: StoreObject | Reference;
25}
26export interface ReadFieldFunction {
27 <V = StoreValue>(options: ReadFieldOptions): SafeReadonly<V> | undefined;
28 <V = StoreValue>(fieldName: string, from?: StoreObject | Reference): SafeReadonly<V> | undefined;
29}
30export declare type ToReferenceFunction = (objOrIdOrRef: StoreObject | string | Reference, mergeIntoStore?: boolean) => Reference | undefined;
31export declare type CanReadFunction = (value: StoreValue) => boolean;
32export declare type Modifier<T> = (value: T, details: {
33 DELETE: any;
34 INVALIDATE: any;
35 fieldName: string;
36 storeFieldName: string;
37 readField: ReadFieldFunction;
38 canRead: CanReadFunction;
39 isReference: typeof isReference;
40 toReference: ToReferenceFunction;
41 storage: StorageType;
42}) => T;
43export declare type Modifiers = {
44 [fieldName: string]: Modifier<any>;
45};
46//# sourceMappingURL=common.d.ts.map
\No newline at end of file