diff --git a/types/react-relay/index.d.ts b/types/react-relay/index.d.ts index 560af286ca..7e9ca3f1a2 100644 --- a/types/react-relay/index.d.ts +++ b/types/react-relay/index.d.ts @@ -140,6 +140,11 @@ interface ConnectionData { pageInfo?: Partial | null; } +export function readInlineData>( + fragment: GraphQLTaggedNode, + ref: FragmentOrRegularProp, +): T; + type FragmentVariablesGetter = (prevVars: Variables, totalCount: number) => Variables; export interface ConnectionConfig { diff --git a/types/react-relay/test/react-relay-tests.tsx b/types/react-relay/test/react-relay-tests.tsx index f18199e7e3..29959236ac 100644 --- a/types/react-relay/test/react-relay-tests.tsx +++ b/types/react-relay/test/react-relay-tests.tsx @@ -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 { + return readInlineData(storyFragment, storyRef); +} + +functionWithInline({ ' $fragmentRefs': _Story_story$ref }); + // ~~~~~~~~~~~~~~~~~~~~~ // Modern Subscriptions // ~~~~~~~~~~~~~~~~~~~~~