mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
add readInlineData (#38462)
* add readInlineData * Update index.d.ts * add tests * fix * lint * add fragment as example
This commit is contained in:
parent
d948328df3
commit
b5dcab9278
5
types/react-relay/index.d.ts
vendored
5
types/react-relay/index.d.ts
vendored
@ -140,6 +140,11 @@ interface ConnectionData {
|
||||
pageInfo?: Partial<PageInfo> | null;
|
||||
}
|
||||
|
||||
export function readInlineData<T extends _RefType<any>>(
|
||||
fragment: GraphQLTaggedNode,
|
||||
ref: FragmentOrRegularProp<T>,
|
||||
): T;
|
||||
|
||||
type FragmentVariablesGetter = (prevVars: Variables, totalCount: number) => Variables;
|
||||
|
||||
export interface ConnectionConfig<Props = object> {
|
||||
|
||||
@ -5,17 +5,19 @@ import * as React from 'react';
|
||||
import { Environment, Network, RecordSource, Store, ConnectionHandler } from 'relay-runtime';
|
||||
|
||||
import {
|
||||
graphql,
|
||||
commitMutation,
|
||||
createFragmentContainer,
|
||||
createPaginationContainer,
|
||||
createRefetchContainer,
|
||||
requestSubscription,
|
||||
QueryRenderer,
|
||||
ReactRelayContext,
|
||||
RelayRefetchProp,
|
||||
RelayPaginationProp,
|
||||
RelayProp,
|
||||
commitMutation,
|
||||
createFragmentContainer,
|
||||
createPaginationContainer,
|
||||
createRefetchContainer,
|
||||
FragmentOrRegularProp,
|
||||
graphql,
|
||||
QueryRenderer,
|
||||
ReactRelayContext,
|
||||
readInlineData,
|
||||
RelayPaginationProp,
|
||||
RelayProp,
|
||||
RelayRefetchProp,
|
||||
requestSubscription,
|
||||
} from 'react-relay';
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -594,6 +596,26 @@ function markNotificationAsRead(source: string, storyID: string) {
|
||||
});
|
||||
}
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
// readInlineData
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
const storyFragment = graphql`
|
||||
fragment Story_story on Todo {
|
||||
id
|
||||
text
|
||||
isPublished
|
||||
}
|
||||
`;
|
||||
|
||||
function functionWithInline(
|
||||
storyRef: FragmentOrRegularProp<Story_story>,
|
||||
): Story_story {
|
||||
return readInlineData<Story_story>(storyFragment, storyRef);
|
||||
}
|
||||
|
||||
functionWithInline({ ' $fragmentRefs': _Story_story$ref });
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
// Modern Subscriptions
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Loading…
Reference in New Issue
Block a user