liaisev5.3.1
/Exports

Reference

Exports

This page lists everything the three entry points export. Look here to find which import a name comes from.

Each entry point is a separate import, and your bundler leaves out what you don’t import. Gzipped, as measured by npm run size for this version:

What you importGzipped
createApi and defineRequest (REST only)about 7.0 kB
REST plus poll and pollUntil9.4 kB
the whole core entry, GraphQL included11.3 kB
the core entry plus all of liaise/middleware12.6 kB

How it compares takes the REST-only figure from the comparison, which bundles one JSON GET, call site included, with the liaise version named on that page. It can differ from the first row above, which is measured on this version’s entry points.

liaise

ExportKindWhat it is
createApifunctionCreates a REST client from your endpoints (createApi options).
withHeadersfunctionA copy of a client that also sends some headers (withHeaders()).
defineRequestfunctionDefines an endpoint, with params checked against the path (Defining endpoints).
RequestclassThe endpoint class that defineRequest builds (Without defineRequest).
paginatefunctionWalks a paginated endpoint, one Result per page (Pagination).
pollfunctionAsks an endpoint on an interval and hands every Result to a callback, until stop() (Polling).
pollUntilfunctionAsks an endpoint on an interval until a condition holds, and resolves with that Result (Polling).
ApiErrorclassThe error of a failed call (Result and ApiError).
createGraphQLfunctionCreates a GraphQL client from your operations (createGraphQL options).
OperationclassDefines one GraphQL operation (Operation options).
gqlfunctionMarks a template string as GraphQL for your editor, and returns it as a plain string.
Result, SuccessResult, ErrorResulttypeWhat every call returns, and its two branches.
ApiErrorKindtypeThe union of error.kind values.
CallOptionstypeThe second argument of a call (CallOptions).
FetchOptionstypeThe options fetchOptions takes: RequestInit without method, headers, body and signal (Cookies and other fetch options).
PaginateOptionstypenext, maxPages, and any CallOptions.
PollabletypeWhat poll and pollUntil take as an endpoint: (params, options?) => Promise<Result>, which every endpoint and operation is.
PollOptions, PollUntilOptionstypeThe options of poll and pollUntil (poll() and pollUntil() options).
WithHeadersOptionstypeThe options of withHeaders: dedupe (withHeaders()).
ApiConfig, RequestConfigtypeThe configs of createApi and an endpoint.
LogOptionstypeThe options of log and logMiddleware(options) (Log options).
GraphQLBaseConfig, OperationConfigtypeThe configs of createGraphQL and an Operation.
GraphQLErrortypeOne entry of a GraphQL errors array.
Middleware, MiddlewareContext, MiddlewareNexttypeA middleware, its ctx, and its next (MiddlewareContext).
StandardSchemaV1, InferOutput, StandardIssuetypeThe Standard Schema interface, the type a schema produces, and one validation issue.

liaise/middleware

ExportKindWhat it is
retryMiddlewarefunctionReturns a middleware that retries failed calls (RetryOptions).
cacheMiddlewarefunctionReturns a middleware that caches successes in memory (Cache options).
logMiddlewaremiddlewareLogs each call to the console. Use it as it is, or call it with options (Log options).
RetryOptions, RetryInfotypeThe options of retryMiddleware, and the argument to onRetry.
CacheMiddlewaretypeWhat cacheMiddleware() returns, a Middleware with clear().
LogMiddlewaretypeThe type of logMiddleware, a Middleware you can also call with LogOptions.

liaise/testing

The test helpers and their types are listed under liaise/testing.

Next: Behaviour in detail covers the edge cases the guide links to.

esc