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 import | Gzipped |
|---|---|
createApi and defineRequest (REST only) | about 7.0 kB |
REST plus poll and pollUntil | 9.4 kB |
| the whole core entry, GraphQL included | 11.3 kB |
the core entry plus all of liaise/middleware | 12.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
| Export | Kind | What it is |
|---|---|---|
createApi | function | Creates a REST client from your endpoints (createApi options). |
withHeaders | function | A copy of a client that also sends some headers (withHeaders()). |
defineRequest | function | Defines an endpoint, with params checked against the path (Defining endpoints). |
Request | class | The endpoint class that defineRequest builds (Without defineRequest). |
paginate | function | Walks a paginated endpoint, one Result per page (Pagination). |
poll | function | Asks an endpoint on an interval and hands every Result to a callback, until stop() (Polling). |
pollUntil | function | Asks an endpoint on an interval until a condition holds, and resolves with that Result (Polling). |
ApiError | class | The error of a failed call (Result and ApiError). |
createGraphQL | function | Creates a GraphQL client from your operations (createGraphQL options). |
Operation | class | Defines one GraphQL operation (Operation options). |
gql | function | Marks a template string as GraphQL for your editor, and returns it as a plain string. |
Result, SuccessResult, ErrorResult | type | What every call returns, and its two branches. |
ApiErrorKind | type | The union of error.kind values. |
CallOptions | type | The second argument of a call (CallOptions). |
FetchOptions | type | The options fetchOptions takes: RequestInit without method, headers, body and signal (Cookies and other fetch options). |
PaginateOptions | type | next, maxPages, and any CallOptions. |
Pollable | type | What poll and pollUntil take as an endpoint: (params, options?) => Promise<Result>, which every endpoint and operation is. |
PollOptions, PollUntilOptions | type | The options of poll and pollUntil (poll() and pollUntil() options). |
WithHeadersOptions | type | The options of withHeaders: dedupe (withHeaders()). |
ApiConfig, RequestConfig | type | The configs of createApi and an endpoint. |
LogOptions | type | The options of log and logMiddleware(options) (Log options). |
GraphQLBaseConfig, OperationConfig | type | The configs of createGraphQL and an Operation. |
GraphQLError | type | One entry of a GraphQL errors array. |
Middleware, MiddlewareContext, MiddlewareNext | type | A middleware, its ctx, and its next (MiddlewareContext). |
StandardSchemaV1, InferOutput, StandardIssue | type | The Standard Schema interface, the type a schema produces, and one validation issue. |
liaise/middleware
| Export | Kind | What it is |
|---|---|---|
retryMiddleware | function | Returns a middleware that retries failed calls (RetryOptions). |
cacheMiddleware | function | Returns a middleware that caches successes in memory (Cache options). |
logMiddleware | middleware | Logs each call to the console. Use it as it is, or call it with options (Log options). |
RetryOptions, RetryInfo | type | The options of retryMiddleware, and the argument to onRetry. |
CacheMiddleware | type | What cacheMiddleware() returns, a Middleware with clear(). |
LogMiddleware | type | The 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.