mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Improve relay-runtime types
This commit is contained in:
9
types/relay-runtime/index.d.ts
vendored
9
types/relay-runtime/index.d.ts
vendored
@@ -60,6 +60,11 @@ export interface OperationDefaults {
|
||||
response: Variables;
|
||||
}
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
// Constants
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
export const ROOT_ID: string;
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
// RelayQL
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -189,7 +194,7 @@ export interface RecordProxy {
|
||||
export interface RecordSourceProxy {
|
||||
create(dataID: DataID, typeName: string): RecordProxy;
|
||||
delete(dataID: DataID): void;
|
||||
get(dataID: DataID): Array<RecordProxy | null> | null;
|
||||
get(dataID: DataID): RecordProxy | null;
|
||||
getRoot(): RecordProxy;
|
||||
}
|
||||
|
||||
@@ -1010,7 +1015,7 @@ export type Observable<T> = RelayObservable<T>;
|
||||
// commitLocalUpdate
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
// exposed through RelayModern, not Runtime directly
|
||||
export type commitLocalUpdate = (environment: Environment, updater: StoreUpdater) => void;
|
||||
export function commitLocalUpdate(environment: Environment, updater: StoreUpdater): void;
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
// commitRelayModernMutation
|
||||
|
||||
@@ -6,6 +6,8 @@ import {
|
||||
ConnectionHandler,
|
||||
ViewerHandler,
|
||||
RecordSourceInspector,
|
||||
commitLocalUpdate,
|
||||
ROOT_ID,
|
||||
} from "relay-runtime";
|
||||
|
||||
const source = new RecordSource();
|
||||
@@ -60,3 +62,12 @@ function handlerProvider(handle: any) {
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
const inspector = new RecordSourceInspector(source);
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
// commitLocalUpdate
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
commitLocalUpdate(environment, store => {
|
||||
const root = store.get(ROOT_ID)!;
|
||||
root.setValue("foo", "localKey");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user