graphql-typed-client
Version:
A tool that generates a strongly typed client library for any GraphQL endpoint. The client allows writing GraphQL queries as plain JS objects (with type safety, awesome code completion experience, custom scalar type mapping, type guards and more)
31 lines (30 loc) • 857 B
TypeScript
import { OperationTypeNode } from 'graphql';
import { LinkedType } from './linkTypeMap';
import { TypeMapper } from './applyTypeMapperToResponse';
export interface Args {
[arg: string]: any | undefined;
}
export interface Fields {
[field: string]: Request;
}
export declare type Request = boolean | number | Fields | [Args, Fields?];
export interface Variables {
[name: string]: {
value: any;
typing: [string, LinkedType];
};
}
export interface Context {
root: LinkedType;
varCounter: number;
variables: Variables;
fragmentCounter: number;
fragments: string[];
}
export interface Gql {
query: string;
variables: {
[name: string]: any;
};
}
export declare const requestToGql: (operation: OperationTypeNode, root: LinkedType, fields: Fields, typeMapper?: TypeMapper | undefined) => Gql;