mirror of
https://github.com/wassname/talk.git
synced 2026-09-09 11:38:08 +08:00
No more patched packages!
This commit is contained in:
@@ -1,22 +1,46 @@
|
||||
import {
|
||||
ConnectionConfig,
|
||||
ConnectionData,
|
||||
createPaginationContainer,
|
||||
FragmentOrRegularProp,
|
||||
GraphQLTaggedNode,
|
||||
RelayPaginationProp,
|
||||
} from "react-relay";
|
||||
import { InferableComponentEnhancerWithProps } from "recompose";
|
||||
import { Variables } from "relay-runtime";
|
||||
import { FragmentKeysNoLocal } from "./types";
|
||||
|
||||
// TODO: (cvle) at some point we might switch these to stock react-relay typings
|
||||
// when they become versatile enough.
|
||||
export type FragmentVariablesGetter<V extends Variables = Variables> = (
|
||||
prevVars: V,
|
||||
totalCount: number
|
||||
) => V;
|
||||
|
||||
export interface ConnectionConfig<
|
||||
P,
|
||||
V extends Variables = Variables,
|
||||
F extends Variables = Variables
|
||||
> {
|
||||
direction?: "backward" | "forward";
|
||||
getConnectionFromProps?(props: P): ConnectionData | undefined | null;
|
||||
getFragmentVariables?: FragmentVariablesGetter<F>;
|
||||
getVariables(
|
||||
props: P,
|
||||
paginationInfo: { count: number; cursor?: string },
|
||||
fragmentVariables: F
|
||||
): V;
|
||||
query: GraphQLTaggedNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* withPaginationContainer is a curried version of `createPaginationContainers`
|
||||
* from Relay.
|
||||
*/
|
||||
export default <T, FragmentVariables, QueryVariables>(
|
||||
export default <T, QueryVariables, FragmentVariables>(
|
||||
fragmentSpec: { [P in FragmentKeysNoLocal<T>]: GraphQLTaggedNode } & {
|
||||
_?: never;
|
||||
},
|
||||
connectionConfig: ConnectionConfig<T, FragmentVariables, QueryVariables>
|
||||
connectionConfig: ConnectionConfig<T, QueryVariables, FragmentVariables>
|
||||
): InferableComponentEnhancerWithProps<
|
||||
{ [P in FragmentKeysNoLocal<T>]: T[P] } & { relay: RelayPaginationProp },
|
||||
{ [P in FragmentKeysNoLocal<T>]: FragmentOrRegularProp<T[P]> }
|
||||
|
||||
Reference in New Issue
Block a user