Under heavy development
StitchAPI
Reference

stitch() & the builder

Signatures for stitch(), defineStitch(), preset(), graphql(), and the fluent builder.

The authoring surface: the four exports that produce a stitch, plus the fluent builder they share. For what goes inside the config object, see Reference → Config types.

stitch()

stitch<T>(config) takes a path string or a partial config and returns a Stitch<T>; stitch.use(...) starts the fluent builder instead.

import {  } from 'stitchapi';

const  = <{ : string }>({
    : 'https://api.example.com/me',
});

defineStitch()

defineStitch(...fragments) binds shared base fragments and returns a stitch() factory; each call deep-merges the bound fragments under the per-call config.

import {  } from 'stitchapi';

const  = ({ : 'https://api.example.com' });
const  = <{ : string }>('/me');

preset()

preset(cfg) is an identity-tagged fragment — a named bundle of reusable defaults you pass through extends. It returns the same Partial<StitchConfig>.

import {  } from 'stitchapi';

const  = ({ : { : 3 } });

graphql()

graphql<T>(config) is a stitch preset for GraphQL-over-HTTP: it POSTs { query, variables } and unwraps data. The config must carry a query.

import {  } from 'stitchapi';

const  = <{ : { : string } }>({
    : 'https://api.example.com/graphql',
    : 'query { viewer { id } }',
});

See Guide → graphql for usage.

The fluent builder

stitch.use(...) returns a Builder: a callable object whose chainable methods accumulate config, then resolve to a stitch when you call it (or .stream() / .with()).

import {  } from 'stitchapi';

const  = .().('https://api.example.com/me');

Prop

Type

Setter methods (.get, .auth, .retry, ...) return the same Builder for chaining; .with() and .stream() build and return a Stitch.

See also

On this page