1 | import { DocumentNode, FieldNode } from 'graphql';
|
2 | import { Reference, StoreObject, StoreValue, isReference } from '../../../utilities';
|
3 | import { StorageType } from '../../inmemory/policies';
|
4 | export type SafeReadonly<T> = T extends object ? Readonly<T> : T;
|
5 | export type MissingTree = string | {
|
6 | readonly [key: string]: MissingTree;
|
7 | };
|
8 | export 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 | }
|
16 | export interface FieldSpecifier {
|
17 | typename?: string;
|
18 | fieldName: string;
|
19 | field?: FieldNode;
|
20 | args?: Record<string, any>;
|
21 | variables?: Record<string, any>;
|
22 | }
|
23 | export interface ReadFieldOptions extends FieldSpecifier {
|
24 | from?: StoreObject | Reference;
|
25 | }
|
26 | export interface ReadFieldFunction {
|
27 | <V = StoreValue>(options: ReadFieldOptions): SafeReadonly<V> | undefined;
|
28 | <V = StoreValue>(fieldName: string, from?: StoreObject | Reference): SafeReadonly<V> | undefined;
|
29 | }
|
30 | export type ToReferenceFunction = (objOrIdOrRef: StoreObject | string | Reference, mergeIntoStore?: boolean) => Reference | undefined;
|
31 | export type CanReadFunction = (value: StoreValue) => boolean;
|
32 | export type ModifierDetails = {
|
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 | };
|
43 | export type Modifier<T> = (value: T, details: ModifierDetails) => T;
|
44 | export type Modifiers = {
|
45 | [fieldName: string]: Modifier<any>;
|
46 | };
|
47 |
|
\ | No newline at end of file |