@types/react-relay
Advanced tools
Comparing version 1.3.15 to 4.0.0
@@ -1,2 +0,2 @@ | ||
// Type definitions for react-relay 1.3 | ||
// Type definitions for react-relay 4.0 | ||
// Project: https://github.com/facebook/relay, https://facebook.github.io/relay | ||
@@ -11,23 +11,58 @@ // Definitions by: Johannes Schickling <https://github.com/graphcool> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 2.9 | ||
// TypeScript Version: 3.0 | ||
// Prettified with: | ||
// $ prettier --parser typescript --tab-width 4 --semi --trailing-comma es5 --write --print-width 120 \ | ||
// types/{react-relay,relay-runtime}/{,*}/*.ts* | ||
export { | ||
commitLocalUpdate, | ||
commitRelayModernMutation as commitMutation, | ||
fetchRelayModernQuery as fetchQuery, | ||
import * as React from 'react'; | ||
import { | ||
Environment, | ||
Variables, | ||
Disposable, | ||
Observer, | ||
CacheConfig, | ||
GraphQLTaggedNode, | ||
requestRelaySubscription as requestSubscription, | ||
RelayContext, | ||
PageInfo, | ||
OperationType, | ||
} from 'relay-runtime'; | ||
import * as React from 'react'; | ||
import * as RelayRuntimeTypes from 'relay-runtime'; | ||
// ./ReactRelayTypes | ||
export interface RelayProp { | ||
environment: Environment; | ||
refetch: undefined; // ensures no RelayRefetchProp is used with a fragment container | ||
hasMore: undefined; // ensures no RelayPaginationProp is used with a fragment container | ||
} | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// Utility types | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export interface RelayRefetchProp { | ||
environment: Environment; | ||
refetch: ( | ||
refetchVariables: Variables | ((fragmentVariables: Variables) => Variables), | ||
renderVariables?: Variables | null, | ||
observerOrCallback?: ObserverOrCallback | null, | ||
options?: RefetchOptions | ||
) => Disposable; | ||
hasMore: undefined; // ensures no RelayPaginationProp is used with a refetch container | ||
} | ||
export interface RefetchOptions { | ||
force?: boolean; | ||
fetchPolicy?: 'store-or-network' | 'network-only'; | ||
} | ||
type ObserverOrCallback = Observer<void> | ((error: Error | null | undefined) => void); | ||
export interface RelayPaginationProp { | ||
readonly environment: Environment; | ||
readonly hasMore: () => boolean; | ||
readonly isLoading: () => boolean; | ||
readonly loadMore: ( | ||
pageSize: number, | ||
observerOrCallback?: ObserverOrCallback | null, | ||
options?: RefetchOptions | null | ||
) => Disposable | null | undefined; | ||
readonly refetchConnection: ( | ||
totalCount: number, | ||
observerOrCallback?: ObserverOrCallback | null, | ||
refetchVariables?: Variables | null | ||
) => Disposable | null | undefined; | ||
refetch: undefined; // ensures no RelayRefetchProp is used with a pagination container | ||
} | ||
export interface _RefType<T> { | ||
@@ -46,158 +81,97 @@ ' $refType': T; | ||
export type MappedFragmentProps<T> = { [K in keyof T]: FragmentOrRegularProp<T[K]> }; | ||
export type MappedFragmentProps<T> = { | ||
[K in keyof T]: FragmentOrRegularProp<T[K]>; | ||
}; | ||
export type RemoveRelayProp<P> = Pick<P, Exclude<keyof P, 'relay'>>; | ||
export { | ||
DataID, | ||
DeclarativeMutationConfig, | ||
Disposable, | ||
Environment, | ||
GraphQLTaggedNode, | ||
MutationType, | ||
NormalizationSelector, | ||
OperationDescriptor, | ||
RangeOperation, | ||
ReaderSelector, | ||
RelayContext, | ||
Snapshot, | ||
Variables, | ||
MutationTypes, | ||
RangeOperations, | ||
applyOptimisticMutation, | ||
commitLocalUpdate, | ||
commitMutation, | ||
fetchQuery, | ||
graphql, | ||
requestSubscription, | ||
} from 'relay-runtime'; | ||
export interface ComponentRef { | ||
componentRef?: (ref: any) => void; | ||
} | ||
export type DataFrom = 'NETWORK_ONLY' | 'STORE_THEN_NETWORK'; | ||
declare class ReactRelayQueryRenderer<TOperation extends OperationType> extends React.Component<{ | ||
cacheConfig?: CacheConfig | null; | ||
dataFrom?: DataFrom; | ||
environment: Environment; | ||
query: GraphQLTaggedNode | null | undefined; | ||
render: (renderProps: { | ||
error: Error | null; | ||
props: TOperation['response'] | null; | ||
retry: (() => void) | null; | ||
}) => React.ReactNode; | ||
variables: TOperation['variables']; | ||
}> {} | ||
export { ReactRelayQueryRenderer as QueryRenderer }; | ||
export type RelayContainer<P> = React.ComponentType<MappedFragmentProps<RemoveRelayProp<P>> & ComponentRef>; | ||
export const ReactRelayContext: React.Context<RelayContext | null>; | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// Maybe Fix | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export type ConcreteFragmentDefinition = object; | ||
export type ConcreteOperationDefinition = object; | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// RelayProp | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// note: refetch and pagination containers augment this | ||
export interface RelayProp { | ||
environment: RelayRuntimeTypes.Environment; | ||
interface GeneratedNodeMap { | ||
[key: string]: GraphQLTaggedNode; | ||
} | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// RelayQL | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export function RelayQL(strings: string[], ...substitutions: any[]): RelayRuntimeTypes.RelayConcreteNode; | ||
export type ContainerProps<Props> = MappedFragmentProps<Pick<Props, Exclude<keyof Props, 'relay'>>>; | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// ReactRelayTypes | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export interface GeneratedNodeMap { | ||
[key: string]: RelayRuntimeTypes.GraphQLTaggedNode; | ||
} | ||
export type Container<Props> = React.ComponentType<ContainerProps<Props> & { componentRef?: (ref: any) => void }>; | ||
/** | ||
* Runtime function to correspond to the `graphql` tagged template function. | ||
* All calls to this function should be transformed by the plugin. | ||
*/ | ||
export interface GraphqlInterface { | ||
(strings: string[] | TemplateStringsArray): RelayRuntimeTypes.GraphQLTaggedNode; | ||
experimental(strings: string[] | TemplateStringsArray): RelayRuntimeTypes.GraphQLTaggedNode; | ||
} | ||
export const graphql: GraphqlInterface; | ||
export function createFragmentContainer<Props>( | ||
Component: React.ComponentType<Props & { relay?: RelayProp }>, | ||
fragmentSpec: GraphQLTaggedNode | GeneratedNodeMap | ||
): Container<Props>; | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// ReactRelayQueryRenderer | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export interface QueryRendererProps<T extends RelayRuntimeTypes.OperationBase = RelayRuntimeTypes.OperationDefaults> { | ||
cacheConfig?: RelayRuntimeTypes.CacheConfig; | ||
dataFrom?: 'NETWORK_ONLY' | 'STORE_THEN_NETWORK'; | ||
environment: RelayRuntimeTypes.Environment; | ||
query?: RelayRuntimeTypes.GraphQLTaggedNode | null; | ||
render(readyState: ReadyState<T['response']>): React.ReactNode; | ||
variables: T['variables']; | ||
rerunParamExperimental?: RelayRuntimeTypes.RerunParam; | ||
interface ConnectionData { | ||
edges?: ReadonlyArray<any> | null; | ||
pageInfo?: Partial<PageInfo> | null; | ||
} | ||
export interface ReadyState<T extends RelayRuntimeTypes.Variables = RelayRuntimeTypes.Variables> { | ||
error: Error | undefined | null; | ||
props: T | undefined | null; | ||
retry?(): void; | ||
} | ||
export class ReactRelayQueryRenderer<T extends RelayRuntimeTypes.OperationBase> extends React.Component< | ||
QueryRendererProps<T> | ||
> {} | ||
export class QueryRenderer< | ||
T extends RelayRuntimeTypes.OperationBase = RelayRuntimeTypes.OperationDefaults | ||
> extends ReactRelayQueryRenderer<T> {} | ||
type FragmentVariablesGetter = (prevVars: Variables, totalCount: number) => Variables; | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// createFragmentContainer | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export function createFragmentContainer<P>( | ||
Component: React.ComponentType<P>, | ||
fragmentSpec: RelayRuntimeTypes.GraphQLTaggedNode | GeneratedNodeMap | ||
): RelayContainer<P>; | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// createPaginationContainer | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export interface PageInfo { | ||
endCursor: string | undefined | null; | ||
hasNextPage: boolean; | ||
hasPreviousPage: boolean; | ||
startCursor: string | undefined | null; | ||
} | ||
export interface ConnectionData { | ||
edges?: ReadonlyArray<any>; | ||
pageInfo?: Partial<PageInfo> | null; | ||
} | ||
export type RelayPaginationProp = RelayProp & { | ||
hasMore(): boolean; | ||
isLoading(): boolean; | ||
loadMore( | ||
pageSize: number, | ||
callback?: ((error?: Error) => void) | null, | ||
options?: RefetchOptions | ||
): RelayRuntimeTypes.Disposable | undefined | null; | ||
refetchConnection( | ||
totalCount: number, | ||
callback: (error?: Error) => void, | ||
refetchVariables?: RelayRuntimeTypes.Variables | ||
): RelayRuntimeTypes.Disposable | undefined | null; | ||
}; | ||
export function FragmentVariablesGetter( | ||
prevVars: RelayRuntimeTypes.Variables, | ||
totalCount: number | ||
): RelayRuntimeTypes.Variables; | ||
export interface ConnectionConfig<P> { | ||
export interface ConnectionConfig<Props = object> { | ||
direction?: 'backward' | 'forward'; | ||
getConnectionFromProps?(props: P): ConnectionData | undefined | null; | ||
getFragmentVariables?: typeof FragmentVariablesGetter; | ||
getVariables( | ||
props: { [propName: string]: any }, | ||
paginationInfo: { count: number; cursor?: string }, | ||
fragmentVariables: RelayRuntimeTypes.Variables | ||
): RelayRuntimeTypes.Variables; | ||
query: RelayRuntimeTypes.GraphQLTaggedNode; | ||
getConnectionFromProps?: (props: Props) => ConnectionData | null | undefined; | ||
getFragmentVariables?: FragmentVariablesGetter; | ||
getVariables: ( | ||
props: Props, | ||
paginationInfo: { count: number; cursor?: string | null }, | ||
fragmentVariables: Variables | ||
) => Variables; | ||
query: GraphQLTaggedNode; | ||
} | ||
export function createPaginationContainer<P>( | ||
Component: React.ComponentType<P>, | ||
fragmentSpec: RelayRuntimeTypes.GraphQLTaggedNode | GeneratedNodeMap, | ||
connectionConfig: ConnectionConfig<P> | ||
): RelayContainer<P>; | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// createRefetchContainer | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export interface RefetchOptions { | ||
force?: boolean; | ||
rerunParamExperimental?: RelayRuntimeTypes.RerunParam; | ||
} | ||
export type RelayRefetchProp = RelayProp & { | ||
refetch( | ||
refetchVariables: | ||
| RelayRuntimeTypes.Variables | ||
| ((fragmentVariables: RelayRuntimeTypes.Variables) => RelayRuntimeTypes.Variables), | ||
renderVariables?: RelayRuntimeTypes.Variables, | ||
callback?: (error?: Error) => void, | ||
options?: RefetchOptions | ||
): RelayRuntimeTypes.Disposable; | ||
}; | ||
export function createRefetchContainer<P>( | ||
Component: React.ComponentType<P>, | ||
fragmentSpec: RelayRuntimeTypes.GraphQLTaggedNode | GeneratedNodeMap, | ||
taggedNode: RelayRuntimeTypes.GraphQLTaggedNode | ||
): RelayContainer<P>; | ||
export function createPaginationContainer<Props>( | ||
Component: React.ComponentType< | ||
Props & { | ||
relay: RelayPaginationProp; | ||
} | ||
>, | ||
fragmentSpec: GraphQLTaggedNode | GeneratedNodeMap, | ||
connectionConfig: ConnectionConfig<Props> | ||
): Container<Props>; | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
// Context | ||
// ~~~~~~~~~~~~~~~~~~~~~ | ||
export const ReactRelayContext: React.Context<RelayRuntimeTypes.CRelayContext<RelayRuntimeTypes.Environment>>; | ||
export function createRefetchContainer<Props>( | ||
Component: React.ComponentType< | ||
Props & { | ||
relay: RelayRefetchProp; | ||
} | ||
>, | ||
fragmentSpec: GraphQLTaggedNode | GeneratedNodeMap, | ||
taggedNode: GraphQLTaggedNode | ||
): Container<Props>; |
{ | ||
"name": "@types/react-relay", | ||
"version": "1.3.15", | ||
"version": "4.0.0", | ||
"description": "TypeScript definitions for react-relay", | ||
@@ -55,4 +55,4 @@ "license": "MIT", | ||
}, | ||
"typesPublisherContentHash": "f93eff0d34ddfdb061f0ed3db70486d24f1b8ded21bad900cbdbe9456adc4a20", | ||
"typeScriptVersion": "2.9" | ||
"typesPublisherContentHash": "31817d53c4a49138310f280c089f690156c2ea11563b97affef8b96914dbfa45", | ||
"typeScriptVersion": "3.0" | ||
} |
@@ -11,4 +11,4 @@ # Installation | ||
Additional Details | ||
* Last updated: Fri, 14 Jun 2019 15:43:33 GMT | ||
* Dependencies: @types/relay-runtime, @types/react | ||
* Last updated: Tue, 18 Jun 2019 14:54:27 GMT | ||
* Dependencies: @types/react, @types/relay-runtime | ||
* Global values: none | ||
@@ -15,0 +15,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9211
4
155
1