fetchero
Version:
_A type-safe, proxy-based HTTP & GraphQL client for modern applications._
27 lines (26 loc) • 1.02 kB
TypeScript
import { FetcherResponse } from './common';
export declare type OperationType = 'query' | 'mutation' | 'subscription';
export interface GraphQLArgs {
[key: string]: {
type: string;
value: unknown;
} | any;
}
export declare type GraphQLResponse<T = unknown> = FetcherResponse<T>;
export interface GraphQLQueryBuilder<T = unknown> {
select(fields: string): Promise<GraphQLResponse<T>>;
execute(): Promise<GraphQLResponse<T>>;
base(newBase: string): GraphQLQueryBuilder<T>;
headers(newHeaders: Record<string, string>): GraphQLQueryBuilder<T>;
}
export declare type ReservedKeys = keyof GraphQLQueryBuilder;
export declare type GraphQLOperationProxy<T = any> = GraphQLQueryBuilder<T> & {
(args?: GraphQLArgs): GraphQLOperationProxy<T>;
} & {
[K in Exclude<string, ReservedKeys>]: GraphQLOperationProxy<T>;
};
export interface GraphQLProxy {
query: GraphQLOperationProxy;
mutation: GraphQLOperationProxy;
subscription: GraphQLOperationProxy;
}