mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
chore: Entria's Relay Experimental no longer needed (#49033)
This commit is contained in:
@@ -1,221 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
import {
|
||||
fetchQuery,
|
||||
RelayEnvironmentProvider,
|
||||
useRelayEnvironment,
|
||||
useQuery,
|
||||
useFragment,
|
||||
useRefetchableFragment,
|
||||
usePaginationFragment,
|
||||
} from 'entria__relay-experimental';
|
||||
import { Environment, RecordSource, Store, Network } from 'relay-runtime';
|
||||
import { graphql } from 'react-relay';
|
||||
|
||||
const source = new RecordSource();
|
||||
const store = new Store(source);
|
||||
|
||||
function cacheHandler(operation: any, variables: { [key: string]: string }, cacheConfig: {}) {
|
||||
return fetch('/graphql', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
query: operation.text, // GraphQL text from input
|
||||
variables,
|
||||
}),
|
||||
}).then((response: any) => {
|
||||
return response.json();
|
||||
});
|
||||
}
|
||||
|
||||
const network = Network.create(cacheHandler);
|
||||
|
||||
const environment = new Environment({
|
||||
network,
|
||||
store,
|
||||
});
|
||||
|
||||
const query = graphql`
|
||||
query SomeQuery {
|
||||
someType
|
||||
}
|
||||
`;
|
||||
|
||||
const variables = {};
|
||||
|
||||
const dispose = fetchQuery(environment, query, variables).subscribe({
|
||||
start: subsctiption => {},
|
||||
next: payload => {},
|
||||
error: (error: Error) => {},
|
||||
complete: () => {},
|
||||
unsubscribe: subscription => {},
|
||||
});
|
||||
|
||||
dispose.unsubscribe();
|
||||
|
||||
function Providers() {
|
||||
return (
|
||||
<RelayEnvironmentProvider environment={environment}>
|
||||
<RelayComponent />
|
||||
</RelayEnvironmentProvider>
|
||||
);
|
||||
}
|
||||
|
||||
function RelayComponent() {
|
||||
const { execute } = useRelayEnvironment();
|
||||
|
||||
return (
|
||||
<React.Suspense fallback={<div>Loading...</div>}>
|
||||
<TodoList />
|
||||
</React.Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
interface Todo {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface Data {
|
||||
variables: {};
|
||||
response: {
|
||||
todos: Todo[];
|
||||
};
|
||||
}
|
||||
|
||||
function TodoList() {
|
||||
const data = useQuery<Data>(
|
||||
graphql`
|
||||
query TodoListQuery {
|
||||
viewer {
|
||||
todos {
|
||||
id
|
||||
...TodoItemFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
null,
|
||||
{ fetchPolicy: 'store-only' },
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{data.todos.map(todo => (
|
||||
<>
|
||||
<TodoItem todo={todo} />
|
||||
<TodoItemRefetchable todo={todo} />
|
||||
</>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
interface TodoItemProps {
|
||||
todo: Todo;
|
||||
}
|
||||
|
||||
function TodoItem(props: TodoItemProps) {
|
||||
const todo = useFragment<Todo>(
|
||||
graphql`
|
||||
fragment TodoItemFragment on Todo {
|
||||
id
|
||||
name
|
||||
}
|
||||
`,
|
||||
props.todo,
|
||||
);
|
||||
|
||||
return <div>{todo.id}</div>;
|
||||
}
|
||||
|
||||
function TodoItemRefetchable(props: TodoItemProps) {
|
||||
const [todo, refetch] = useRefetchableFragment(
|
||||
graphql`
|
||||
fragment TodoItemFragment on Todo @refetchable(queryName: "TodoItemFragmentRefetchQuery") {
|
||||
text
|
||||
isComplete
|
||||
}
|
||||
`,
|
||||
props.todo,
|
||||
);
|
||||
|
||||
refetch(
|
||||
{ id: 'id:2' },
|
||||
{
|
||||
onComplete: error => {
|
||||
console.info('teste');
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
return <div>todo.name</div>;
|
||||
}
|
||||
|
||||
interface User {
|
||||
id: string;
|
||||
name: string;
|
||||
todos: Todo[];
|
||||
}
|
||||
interface UserData {
|
||||
variables: {};
|
||||
response: {
|
||||
node: User;
|
||||
};
|
||||
}
|
||||
|
||||
function User() {
|
||||
const { node } = useQuery<UserData>(
|
||||
graphql`
|
||||
query UserQuery($id: ID!, $last: Int, $first: Int, $after: ID, $before: ID) {
|
||||
node(id: $id) {
|
||||
...UserFragment
|
||||
}
|
||||
}
|
||||
`,
|
||||
{
|
||||
id: '1',
|
||||
first: 1,
|
||||
last: null,
|
||||
before: null,
|
||||
after: 'cursor:1',
|
||||
},
|
||||
);
|
||||
|
||||
return <UserTodos user={node} />;
|
||||
}
|
||||
|
||||
interface UserTodosProps {
|
||||
user: User;
|
||||
}
|
||||
|
||||
function UserTodos(props: UserTodosProps) {
|
||||
const {
|
||||
data,
|
||||
hasNext,
|
||||
hasPrevious,
|
||||
isLoadingNext,
|
||||
isLoadingPrevious,
|
||||
loadNext,
|
||||
loadPrevious,
|
||||
refetch,
|
||||
} = usePaginationFragment(
|
||||
graphql`
|
||||
fragment UserFragment on User @refetchable(queryName: "UserFragmentPaginationQuery") {
|
||||
id
|
||||
name
|
||||
todos(first: $first, last: $last, after: $after, before: $before)
|
||||
@connection(key: "UserFragment_todos") {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
...TodoFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
props.user,
|
||||
);
|
||||
|
||||
return <div>{data.name}</div>;
|
||||
}
|
||||
19
types/entria__relay-experimental/index.d.ts
vendored
19
types/entria__relay-experimental/index.d.ts
vendored
@@ -1,19 +0,0 @@
|
||||
// Type definitions for @entria/relay-experimental 6.0
|
||||
// Project: https://github.com/facebook/relay
|
||||
// Definitions by: Renan Machado <https://github.com/renanmav>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.7
|
||||
|
||||
export { fetchQuery } from './lib/fetchQuery';
|
||||
export { RelayEnvironmentProvider } from './lib/RelayEnvironmentProvider';
|
||||
export { useRelayEnvironment } from './lib/useRelayEnvironment';
|
||||
export { Direction, LoadMoreFn } from './lib/useLoadMoreFunction';
|
||||
export { RefetchFn, Options as RefetchOptions } from './lib/useRefetchableFragmentNode';
|
||||
|
||||
export { FetchPolicy } from './lib/QueryResource';
|
||||
|
||||
export { useQuery } from './lib/useQuery';
|
||||
export { useFragment } from './lib/useFragment';
|
||||
export { useRefetchableFragment } from './lib/useRefetchableFragment';
|
||||
export { useLegacyPaginationFragment as usePaginationFragment } from './lib/useLegacyPaginationFragment';
|
||||
export { useLegacyPaginationFragment } from './lib/useLegacyPaginationFragment';
|
||||
@@ -1,46 +0,0 @@
|
||||
export interface Cache<T> {
|
||||
get(key: string): T | null;
|
||||
set(key: string, value: T): void;
|
||||
has(key: string): boolean;
|
||||
delete(key: string): void;
|
||||
size(): number;
|
||||
capacity(): number;
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* JS maps (both plain objects and Map) maintain key insertion
|
||||
* order, which means there is an easy way to simulate LRU behavior
|
||||
* that should also perform quite well:
|
||||
*
|
||||
* To insert a new value, first delete the key from the inner _map,
|
||||
* then _map.set(k, v). By deleting and reinserting, you ensure that the
|
||||
* map sees the key as the last inserted key.
|
||||
*
|
||||
* Get does the same: if the key is present, delete and reinsert it.
|
||||
*/
|
||||
declare class LRUCache<T> implements Cache<T> {
|
||||
_capacity: number;
|
||||
_map: Map<string, T>;
|
||||
|
||||
constructor(capacity: number);
|
||||
|
||||
set(key: string, value: T): void;
|
||||
|
||||
get(key: string): T | null;
|
||||
|
||||
has(key: string): boolean;
|
||||
|
||||
delete(key: string): void;
|
||||
|
||||
size(): number;
|
||||
|
||||
capacity(): number;
|
||||
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-unnecessary-generics
|
||||
declare function create<T>(capacity: number): LRUCache<T>;
|
||||
|
||||
export { create };
|
||||
@@ -1,84 +0,0 @@
|
||||
import {
|
||||
Disposable,
|
||||
FragmentPointer,
|
||||
GraphQLResponse,
|
||||
IEnvironment,
|
||||
Observable,
|
||||
Observer,
|
||||
OperationDescriptor,
|
||||
ReaderFragment,
|
||||
Snapshot,
|
||||
} from 'relay-runtime';
|
||||
import { Cache } from './LRUCache';
|
||||
|
||||
export type QueryResource = QueryResourceImpl;
|
||||
export type FetchPolicy = 'store-only' | 'store-or-network' | 'store-and-network' | 'network-only';
|
||||
export type RenderPolicy = 'full' | 'partial';
|
||||
|
||||
type QueryResourceCache = Cache<QueryResourceCacheEntry>;
|
||||
interface QueryResourceCacheEntry {
|
||||
readonly cacheKey: string;
|
||||
getRetainCount(): number;
|
||||
getValue(): Error | Promise<void> | QueryResult;
|
||||
setValue(value: Error | Promise<void> | QueryResult): void;
|
||||
temporaryRetain(environment: IEnvironment): void;
|
||||
permanentRetain(environment: IEnvironment): Disposable;
|
||||
}
|
||||
interface QueryResult {
|
||||
cacheKey: string;
|
||||
fragmentNode: ReaderFragment;
|
||||
fragmentRef: FragmentPointer;
|
||||
operation: OperationDescriptor;
|
||||
}
|
||||
|
||||
declare function getQueryCacheKey(
|
||||
operation: OperationDescriptor,
|
||||
fetchPolicy: FetchPolicy,
|
||||
renderPolicy: RenderPolicy,
|
||||
): string;
|
||||
|
||||
declare function getQueryResult(operation: OperationDescriptor, cacheKey: string): QueryResult;
|
||||
|
||||
declare function createQueryResourceCacheEntry(
|
||||
cacheKey: string,
|
||||
operation: OperationDescriptor,
|
||||
value: Error | Promise<void> | QueryResult,
|
||||
onDispose: (entry: QueryResourceCacheEntry) => void,
|
||||
): QueryResourceCacheEntry;
|
||||
|
||||
declare class QueryResourceImpl {
|
||||
constructor(environment: IEnvironment);
|
||||
|
||||
/**
|
||||
* This function should be called during a Component's render function,
|
||||
* to either read an existing cached value for the query, or fetch the query
|
||||
* and suspend.
|
||||
*/
|
||||
prepare(
|
||||
operation: OperationDescriptor,
|
||||
fetchObservable: Observable<GraphQLResponse>,
|
||||
maybeFetchPolicy: FetchPolicy | null,
|
||||
maybeRenderPolicy: RenderPolicy | null,
|
||||
observer?: Observer<Snapshot>,
|
||||
cacheKeyBuster?: string | number,
|
||||
): QueryResult;
|
||||
|
||||
/**
|
||||
* This function should be called during a Component's commit phase
|
||||
* (e.g. inside useEffect), in order to retain the operation in the Relay store
|
||||
* and transfer ownership of the operation to the component lifecycle.
|
||||
*/
|
||||
retain(queryResult: QueryResult): Disposable;
|
||||
|
||||
getCacheEntry(
|
||||
operation: OperationDescriptor,
|
||||
fetchPolicy: FetchPolicy,
|
||||
maybeRenderPolicy?: RenderPolicy,
|
||||
): QueryResourceCacheEntry | null;
|
||||
}
|
||||
|
||||
declare function createQueryResource(environment: IEnvironment): QueryResource;
|
||||
|
||||
declare function getQueryResourceForEnvironment(environment: IEnvironment): QueryResourceImpl;
|
||||
|
||||
export { createQueryResource, getQueryResourceForEnvironment };
|
||||
@@ -1,9 +0,0 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { IEnvironment } from 'relay-runtime';
|
||||
|
||||
export interface Props {
|
||||
children: ReactNode;
|
||||
environment: IEnvironment;
|
||||
}
|
||||
|
||||
export function RelayEnvironmentProvider(props: Props): JSX.Element;
|
||||
@@ -1,85 +0,0 @@
|
||||
import { CacheConfig, GraphQLTaggedNode, IEnvironment, Observable, OperationType } from 'relay-runtime';
|
||||
|
||||
/**
|
||||
* Fetches the given query and variables on the provided environment,
|
||||
* and de-dupes identical in-flight requests.
|
||||
*
|
||||
* Observing a request:
|
||||
* ====================
|
||||
* fetchQuery returns an Observable which you can call .subscribe()
|
||||
* on. Subscribe optionally takes an Observer, which you can provide to
|
||||
* observe network events:
|
||||
*
|
||||
* ```
|
||||
* fetchQuery(environment, query, variables).subscribe({
|
||||
* // Called when network requests starts
|
||||
* start: (subsctiption) => {},
|
||||
*
|
||||
* // Called after a payload is received and written to the local store
|
||||
* next: (payload) => {},
|
||||
*
|
||||
* // Called when network requests errors
|
||||
* error: (error) => {},
|
||||
*
|
||||
* // Called when network requests fully completes
|
||||
* complete: () => {},
|
||||
*
|
||||
* // Called when network request is unsubscribed
|
||||
* unsubscribe: (subscription) => {},
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Request Promise:
|
||||
* ================
|
||||
* The obervable can be converted to a Promise with .toPromise(), which will
|
||||
* resolve to a snapshot of the query data when the first response is received
|
||||
* from the server.
|
||||
*
|
||||
* ```
|
||||
* fetchQuery(environment, query, variables).then((data) => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* In-flight request de-duping:
|
||||
* ============================
|
||||
* By default, calling fetchQuery multiple times with the same
|
||||
* environment, query and variables will not initiate a new request if a request
|
||||
* for those same parameters is already in flight.
|
||||
*
|
||||
* A request is marked in-flight from the moment it starts until the moment it
|
||||
* fully completes, regardless of error or successful completion.
|
||||
*
|
||||
* NOTE: If the request completes _synchronously_, calling fetchQuery
|
||||
* a second time with the same arguments in the same tick will _NOT_ de-dupe
|
||||
* the request given that it will no longer be in-flight.
|
||||
*
|
||||
*
|
||||
* Data Retention:
|
||||
* ===============
|
||||
* This function will NOT retain query data, meaning that it is not guaranteed
|
||||
* that the fetched data will remain in the Relay store after the request has
|
||||
* completed.
|
||||
* If you need to retain the query data outside of the network request,
|
||||
* you need to use `environment.retain()`.
|
||||
*
|
||||
*
|
||||
* Cancelling requests:
|
||||
* ====================
|
||||
* If the disposable returned by subscribe is called while the
|
||||
* request is in-flight, the request will be cancelled.
|
||||
*
|
||||
* ```
|
||||
* const disposable = fetchQuery(...).subscribe(...);
|
||||
*
|
||||
* // This will cancel the request if it is in-flight.
|
||||
* disposable.dispose();
|
||||
* ```
|
||||
* NOTE: When using .toPromise(), the request cannot be cancelled.
|
||||
*/
|
||||
export function fetchQuery<TQuery extends OperationType>(
|
||||
environment: IEnvironment,
|
||||
query: GraphQLTaggedNode,
|
||||
variables: TQuery['variables'],
|
||||
options?: { networkCacheConfig?: CacheConfig },
|
||||
): Observable<TQuery['response']>;
|
||||
@@ -1,37 +0,0 @@
|
||||
import { GraphQLTaggedNode } from 'relay-runtime';
|
||||
|
||||
// NOTE: These declares ensure that the type of the returned data is:
|
||||
// - non-nullable if the provided ref type is non-nullable
|
||||
// - nullable if the provided ref type is nullable
|
||||
// - array of non-nullable if the privoided ref type is an array of
|
||||
// non-nullable refs
|
||||
// - array of nullable if the privoided ref type is an array of nullable refs
|
||||
|
||||
export type NonNullableReturn<TFragmentData> = (data?: TFragmentData) => TFragmentData;
|
||||
export type NonNullableFragmentReturn<T> = ReturnType<NonNullableReturn<T>>;
|
||||
|
||||
export type NullableReturn<TFragmentData> = (data?: TFragmentData) => TFragmentData | null;
|
||||
export type NullableFragmentReturn<T> = ReturnType<NullableReturn<T>>;
|
||||
|
||||
export type NonNullableArrayReturn<TFragmentData> = (data?: ReadonlyArray<TFragmentData>) => TFragmentData;
|
||||
export type NonNullableArrayFragmentReturn<T> = ReturnType<NonNullableArrayReturn<T>>;
|
||||
|
||||
export type NullableArrayReturn<TFragmentData> = (data?: ReadonlyArray<TFragmentData>) => TFragmentData | null;
|
||||
export type NullableArrayFragmentReturn<T> = ReturnType<NullableArrayReturn<T>>;
|
||||
|
||||
export function useFragment<TKey extends { readonly [key: string]: any }>(
|
||||
fragmentInput: GraphQLTaggedNode,
|
||||
fragmentRef: TKey,
|
||||
): NonNullableFragmentReturn<TKey>;
|
||||
export function useFragment<TKey extends { readonly [key: string]: any } | null>(
|
||||
fragmentInput: GraphQLTaggedNode,
|
||||
fragmentRef: TKey,
|
||||
): NullableFragmentReturn<TKey>;
|
||||
export function useFragment<TKey extends ReadonlyArray<{ readonly [key: string]: any }>>(
|
||||
fragmentInput: GraphQLTaggedNode,
|
||||
fragmentRef: TKey,
|
||||
): NonNullableArrayFragmentReturn<TKey>;
|
||||
export function useFragment<TKey extends ReadonlyArray<{ readonly [key: string]: any }> | null>(
|
||||
fragmentInput: GraphQLTaggedNode,
|
||||
fragmentRef: TKey,
|
||||
): NullableArrayFragmentReturn<TKey>;
|
||||
@@ -1,29 +0,0 @@
|
||||
import { LoadMoreFn, UseLoadMoreFunctionArgs } from './useLoadMoreFunction';
|
||||
import { RefetchFnDynamic } from './useRefetchableFragmentNode';
|
||||
import { GraphQLResponse, GraphQLTaggedNode, Observer, OperationType } from 'relay-runtime';
|
||||
|
||||
export interface ReturnTypePaginationFragment<TQuery extends OperationType, TKey, TFragmentData> {
|
||||
data: TFragmentData;
|
||||
loadNext: LoadMoreFn;
|
||||
loadPrevious: LoadMoreFn;
|
||||
hasNext: boolean;
|
||||
hasPrevious: boolean;
|
||||
isLoadingNext: boolean;
|
||||
isLoadingPrevious: boolean;
|
||||
refetch: RefetchFnDynamic<TQuery, TKey>;
|
||||
}
|
||||
|
||||
export type NonNullableReturn<TFragmentData> = (data?: TFragmentData) => TFragmentData;
|
||||
export type NonNullableFragmentReturn<TReturn> = ReturnType<NonNullableReturn<TReturn>>;
|
||||
|
||||
export type NullableReturn<TFragmentData> = (data?: TFragmentData | null) => TFragmentData | null;
|
||||
export type NullableFragmentReturn<TReturn> = ReturnType<NullableReturn<TReturn>>;
|
||||
|
||||
export function useLegacyPaginationFragment<
|
||||
TQuery extends OperationType,
|
||||
TKey extends { readonly [key: string]: any } | null
|
||||
>(
|
||||
fragmentInput: GraphQLTaggedNode,
|
||||
parentFragmentRef: TKey,
|
||||
): // tslint:disable-next-line no-unnecessary-generics
|
||||
ReturnTypePaginationFragment<TQuery, TKey, NonNullableFragmentReturn<TKey> & NullableFragmentReturn<TKey>>;
|
||||
@@ -1,45 +0,0 @@
|
||||
import {
|
||||
ConcreteRequest,
|
||||
Disposable,
|
||||
GraphQLResponse,
|
||||
Observer,
|
||||
ReaderFragment,
|
||||
ReaderPaginationMetadata,
|
||||
RequestDescriptor,
|
||||
} from 'relay-runtime';
|
||||
|
||||
export type Direction = 'forward' | 'backward';
|
||||
|
||||
export type LoadMoreFn = (
|
||||
count: number,
|
||||
options?: {
|
||||
onComplete?: (arg: Error | null) => void;
|
||||
},
|
||||
) => Disposable;
|
||||
|
||||
export interface UseLoadMoreFunctionArgs {
|
||||
direction: Direction;
|
||||
fragmentNode: ReaderFragment;
|
||||
fragmentIdentifier: string;
|
||||
fragmentOwner: RequestDescriptor | ReadonlyArray<RequestDescriptor | null> | null;
|
||||
fragmentData: unknown;
|
||||
connectionPathInFragmentData: ReadonlyArray<string | number>;
|
||||
fragmentRefPathInResponse: ReadonlyArray<string | number>;
|
||||
paginationRequest: ConcreteRequest;
|
||||
paginationMetadata: ReaderPaginationMetadata;
|
||||
componentDisplayName: string;
|
||||
observer: Observer<GraphQLResponse>;
|
||||
onReset: () => void;
|
||||
}
|
||||
|
||||
export function useLoadMoreFunction(args: UseLoadMoreFunctionArgs): [LoadMoreFn, boolean, () => void];
|
||||
|
||||
export function getConnectionState(
|
||||
direction: Direction,
|
||||
fragmentNode: ReaderFragment,
|
||||
fragmentData: unknown,
|
||||
connectionPathInFragmentData: ReadonlyArray<string | number>,
|
||||
): {
|
||||
cursor: string | null;
|
||||
hasMore: boolean;
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
import { FetchPolicy } from './QueryResource';
|
||||
import { CacheConfig, GraphQLTaggedNode, OperationType } from 'relay-runtime';
|
||||
|
||||
export function useQuery<TQuery extends OperationType>(
|
||||
gqlQuery: GraphQLTaggedNode,
|
||||
variables?: TQuery['variables'] | null,
|
||||
options?: {
|
||||
fetchKey?: string | number;
|
||||
fetchPolicy?: FetchPolicy;
|
||||
networkCacheConfig?: CacheConfig;
|
||||
},
|
||||
): TQuery['response'];
|
||||
@@ -1,25 +0,0 @@
|
||||
import { RefetchFnDynamic } from './useRefetchableFragmentNode';
|
||||
import { GraphQLTaggedNode, OperationType } from 'relay-runtime';
|
||||
|
||||
export type ReturnTypeRefetchableFragment<
|
||||
TQuery extends OperationType,
|
||||
TKey extends { readonly [key: string]: any } | null
|
||||
> = [
|
||||
// NOTE: This ReturnType ensures that the type of the returned data is either:
|
||||
// - nullable if the provided ref type is nullable
|
||||
// - non-nullable if the provided ref type is non-nullable
|
||||
NonNullableFragmentReturn<TKey> & NullableFragmentReturn<TKey>,
|
||||
RefetchFnDynamic<TQuery, TKey>,
|
||||
];
|
||||
|
||||
export type NonNullableReturn<TFragmentData> = (data?: TFragmentData) => TFragmentData;
|
||||
export type NonNullableFragmentReturn<TReturn> = ReturnType<NonNullableReturn<TReturn>>;
|
||||
|
||||
export type NullableReturn<TFragmentData> = (data?: TFragmentData | null) => TFragmentData | null;
|
||||
export type NullableFragmentReturn<TReturn> = ReturnType<NullableReturn<TReturn>>;
|
||||
|
||||
export function useRefetchableFragment<
|
||||
TQuery extends OperationType,
|
||||
TKey extends { readonly [key: string]: any } | null
|
||||
// tslint:disable-next-line:no-unnecessary-generics
|
||||
>(fragmentInput: GraphQLTaggedNode, fragmentRef: TKey): ReturnTypeRefetchableFragment<TQuery, TKey>;
|
||||
@@ -1,124 +0,0 @@
|
||||
import { Disposable, OperationType, IEnvironment, Variables, ReaderFragment } from 'relay-runtime';
|
||||
|
||||
import { FetchPolicy, RenderPolicy } from './QueryResource';
|
||||
|
||||
export type RefetchFn<TQuery extends OperationType, TOptions = Options> = RefetchFnExact<TQuery, TOptions>;
|
||||
|
||||
export type RefetchFnDynamic<
|
||||
TQuery extends OperationType,
|
||||
TKey extends { readonly [key: string]: any } | null,
|
||||
TOptions = Options
|
||||
> = RefetchInexactDynamicResponse<TQuery, TOptions> & RefetchExactDynamicResponse<TQuery, TOptions>;
|
||||
|
||||
export type RefetchInexact<TQuery extends OperationType, TOptions> = (
|
||||
data?: unknown,
|
||||
) => RefetchFnInexact<TQuery, TOptions>;
|
||||
export type RefetchInexactDynamicResponse<TQuery extends OperationType, TOptions> = ReturnType<
|
||||
RefetchInexact<TQuery, TOptions>
|
||||
>;
|
||||
|
||||
export type RefetchExact<TQuery extends OperationType, TOptions> = (
|
||||
data?: unknown | null,
|
||||
) => RefetchFnExact<TQuery, TOptions>;
|
||||
export type RefetchExactDynamicResponse<TQuery extends OperationType, TOptions> = ReturnType<
|
||||
RefetchExact<TQuery, TOptions>
|
||||
>;
|
||||
|
||||
export type RefetchFnBase<TVars, TOptions> = (vars: TVars, options?: TOptions) => Disposable;
|
||||
|
||||
export type RefetchFnExact<TQuery extends OperationType, TOptions = Options> = RefetchFnBase<
|
||||
TQuery['variables'],
|
||||
TOptions
|
||||
>;
|
||||
export type RefetchFnInexact<TQuery extends OperationType, TOptions = Options> = RefetchFnBase<
|
||||
TQuery['variables'],
|
||||
TOptions
|
||||
>;
|
||||
|
||||
export interface ReturnTypeNode<
|
||||
TQuery extends OperationType,
|
||||
TKey extends { readonly [key: string]: any } | null,
|
||||
TOptions = Options
|
||||
> {
|
||||
fragmentData: unknown;
|
||||
fragmentRef: unknown;
|
||||
refetch: RefetchFnDynamic<TQuery, TKey, TOptions>;
|
||||
disableStoreUpdates: () => void;
|
||||
enableStoreUpdates: () => void;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
fetchPolicy?: FetchPolicy;
|
||||
onComplete?: (arg: Error | null) => void;
|
||||
}
|
||||
|
||||
export interface InternalOptions extends Options {
|
||||
__environment?: IEnvironment;
|
||||
renderPolicy?: RenderPolicy;
|
||||
}
|
||||
|
||||
export type Action =
|
||||
| {
|
||||
type: string;
|
||||
environment: IEnvironment;
|
||||
fragmentIdentifier: string;
|
||||
}
|
||||
| {
|
||||
type: string;
|
||||
refetchVariables: Variables;
|
||||
fetchPolicy?: FetchPolicy;
|
||||
renderPolicy?: RenderPolicy;
|
||||
onComplete?: (args: Error | null) => void;
|
||||
environment: IEnvironment;
|
||||
};
|
||||
|
||||
export interface RefetchState {
|
||||
fetchPolicy: FetchPolicy | undefined;
|
||||
renderPolicy: RenderPolicy | undefined;
|
||||
mirroredEnvironment: IEnvironment;
|
||||
mirroredFragmentIdentifier: string;
|
||||
onComplete: ((arg: Error | null) => void) | undefined;
|
||||
refetchEnvironment?: IEnvironment | null;
|
||||
refetchVariables?: Variables | null;
|
||||
}
|
||||
|
||||
export interface DebugIDandTypename {
|
||||
id: string;
|
||||
typename: string;
|
||||
}
|
||||
|
||||
export function reducer(state: RefetchState, action: Action): RefetchState;
|
||||
|
||||
export function useRefetchableFragmentNode<
|
||||
TQuery extends OperationType,
|
||||
TKey extends { readonly [key: string]: any } | null
|
||||
>(
|
||||
fragmentNode: ReaderFragment,
|
||||
parentFragmentRef: unknown,
|
||||
componentDisplayName: string,
|
||||
): // tslint:disable-next-line:no-unnecessary-generics
|
||||
ReturnTypeNode<TQuery, TKey, InternalOptions>;
|
||||
|
||||
export function useRefetchFunction<TQuery extends OperationType>(
|
||||
fragmentNode: any,
|
||||
parentFragmentRef: any,
|
||||
fragmentIdentifier: any,
|
||||
fragmentRefPathInResponse: any,
|
||||
fragmentData: any,
|
||||
refetchGenerationRef: any,
|
||||
dispatch: any,
|
||||
disposeFetch: any,
|
||||
componentDisplayName: any,
|
||||
): // tslint:disable-next-line:no-unnecessary-generics
|
||||
RefetchFn<TQuery, InternalOptions>;
|
||||
|
||||
export function readQuery(
|
||||
environment: any,
|
||||
query: any,
|
||||
fetchPolicy: any,
|
||||
renderPolicy: any,
|
||||
refetchGeneration: any,
|
||||
componentDisplayName: any,
|
||||
{ start, complete }: any,
|
||||
profilerContext: any,
|
||||
): any;
|
||||
@@ -1,3 +0,0 @@
|
||||
import { IEnvironment } from 'relay-runtime';
|
||||
|
||||
export function useRelayEnvironment(): IEnvironment;
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6", "dom"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"paths": {
|
||||
"@entria/*": ["entria__*"]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"jsx": "react",
|
||||
"experimentalDecorators": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": ["index.d.ts", "entria__relay-experimental-tests.tsx"]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{ "extends": "dtslint/dt.json", "rules": {} }
|
||||
Reference in New Issue
Block a user