Skip to content

Commit afb812e

Browse files
authored
🤖 Merge PR DefinitelyTyped#64435 [relay-runtime] Add inject() in relay-runtime ConnectionInteface by @vladstoick
1 parent 1d97fd5 commit afb812e

File tree

2 files changed

+44
-13
lines changed

2 files changed

+44
-13
lines changed

‎types/relay-runtime/lib/handlers/connection/ConnectionInterface.d.ts‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@ export interface PageInfo {
1212
startCursor: string | null | undefined;
1313
}
1414

15+
interface ConnectionConfig {
16+
CURSOR: string;
17+
EDGES: string;
18+
END_CURSOR: string;
19+
HAS_NEXT_PAGE: string;
20+
HAS_PREV_PAGE: string;
21+
NODE: string;
22+
PAGE_INFO: string;
23+
PAGE_INFO_TYPE: string;
24+
START_CURSOR: string;
25+
}
26+
1527
declare const ConnectionInterface: {
16-
get(): {
17-
CLIENT_MUTATION_ID: 'clientMutationId';
18-
CURSOR: 'cursor';
19-
EDGES_HAVE_SOURCE_FIELD: boolean;
20-
EDGES: 'edges';
21-
END_CURSOR: 'endCursor';
22-
HAS_NEXT_PAGE: 'hasNextPage';
23-
HAS_PREV_PAGE: 'hasPreviousPage';
24-
NODE: 'node';
25-
PAGE_INFO_TYPE: 'PageInfo';
26-
PAGE_INFO: 'pageInfo';
27-
START_CURSOR: 'startCursor';
28-
};
28+
get(): ConnectionConfig;
29+
30+
inject(newConfig: ConnectionConfig): void;
2931
};
3032

3133
export default ConnectionInterface;

‎types/relay-runtime/relay-runtime-tests.tsx‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
readInlineData,
2626
requestSubscription,
2727
fetchQuery,
28+
ConnectionInterface,
2829
} from 'relay-runtime';
2930

3031
import * as multiActorEnvironment from 'relay-runtime/multi-actor-environment';
@@ -686,3 +687,31 @@ requestSubscription(environment, {
686687
onNext: (_response) => { return; },
687688
updater: (_store, _data) => { return; },
688689
});
690+
691+
// ~~~~~~~~~~~~~~~~~~~~~
692+
// ConnectionInterface
693+
// ~~~~~~~~~~~~~~~~~~~~~
694+
695+
const {
696+
CURSOR,
697+
EDGES,
698+
END_CURSOR,
699+
HAS_NEXT_PAGE,
700+
HAS_PREV_PAGE,
701+
NODE,
702+
PAGE_INFO,
703+
PAGE_INFO_TYPE,
704+
START_CURSOR
705+
} = ConnectionInterface.get();
706+
707+
ConnectionInterface.inject({
708+
CURSOR: 'cursor',
709+
EDGES: 'edges',
710+
END_CURSOR: 'endCursor',
711+
HAS_NEXT_PAGE: 'hasNextPage',
712+
HAS_PREV_PAGE: 'hasPrevPage',
713+
NODE: 'node',
714+
PAGE_INFO: 'pageInfo',
715+
PAGE_INFO_TYPE: 'PageInfo',
716+
START_CURSOR: 'startCursor',
717+
});

0 commit comments

Comments
 (0)