diff --git a/src/index.ts b/src/index.ts index cdfb1bb93..f5def789a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,21 +35,6 @@ import { import type { TypedDocumentNode } from '@graphql-typed-document-node/core' import crossFetch, * as CrossFetch from 'cross-fetch' -export { - BatchRequestDocument, - BatchRequestsExtendedOptions, - BatchRequestsOptions, - ClientError, - RawRequestExtendedOptions, - RawRequestOptions, - RequestDocument, - RequestExtendedOptions, - RequestMiddleware, - RequestOptions, - ResponseMiddleware, - Variables, -} - /** * Convert the given headers configuration into a plain object. */ @@ -197,7 +182,7 @@ const createHttpMethodFetcher = /** * GraphQL Client. */ -export class GraphQLClient { +class GraphQLClient { constructor(private url: string, public readonly requestConfig: RequestConfig = {}) {} /** @@ -471,7 +456,7 @@ type RawRequestArgs = /** * Send a GraphQL Query to the GraphQL server for execution. */ -export const rawRequest: RawRequest = async ( +const rawRequest: RawRequest = async ( ...args: RawRequestArgs ): Promise> => { const [urlOrOptions, query, ...variablesAndRequestHeaders] = args @@ -517,12 +502,12 @@ export const rawRequest: RawRequest = async ( * ``` */ // prettier-ignore -export async function request(url: string, document: RequestDocument | TypedDocumentNode, ...variablesAndRequestHeaders: VariablesAndRequestHeadersArgs): Promise +async function request(url: string, document: RequestDocument | TypedDocumentNode, ...variablesAndRequestHeaders: VariablesAndRequestHeadersArgs): Promise // prettier-ignore -export async function request(options: RequestExtendedOptions): Promise +async function request(options: RequestExtendedOptions): Promise // prettier-ignore // eslint-disable-next-line -export async function request(urlOrOptions: string | RequestExtendedOptions, document?: RequestDocument | TypedDocumentNode, ...variablesAndRequestHeaders: VariablesAndRequestHeadersArgs): Promise { +async function request(urlOrOptions: string | RequestExtendedOptions, document?: RequestDocument | TypedDocumentNode, ...variablesAndRequestHeaders: VariablesAndRequestHeadersArgs): Promise { const requestOptions = parseRequestExtendedArgs(urlOrOptions, document, ...variablesAndRequestHeaders) const client = new GraphQLClient(requestOptions.url) return client.request({ @@ -564,7 +549,7 @@ export async function request(urlOrOptions: * await batchRequests('https://foo.bar/graphql', [{ query: gql`...` }]) * ``` */ -export const batchRequests: BatchRequests = async (...args: BatchRequestsArgs) => { +const batchRequests: BatchRequests = async (...args: BatchRequestsArgs) => { const params = parseBatchRequestsArgsExtended(args) const client = new GraphQLClient(params.url) return client.batchRequests(params) @@ -682,4 +667,22 @@ export const gql = (chunks: TemplateStringsArray, ...variables: unknown[]): stri export { GraphQLWebSocketClient } from './graphql-ws.js' export { resolveRequestDocument } from './resolveRequestDocument.js' +export { + BatchRequestDocument, + batchRequests, + BatchRequestsExtendedOptions, + BatchRequestsOptions, + ClientError, + GraphQLClient, + rawRequest, + RawRequestExtendedOptions, + RawRequestOptions, + request, + RequestDocument, + RequestExtendedOptions, + RequestMiddleware, + RequestOptions, + ResponseMiddleware, + Variables, +} export default request