Skip to main content
browser.BijectionClient Subscribes to Bijection query functions and executes mutations and actions over a WebSocket. Optimistic updates for mutations are not provided for this client. Third party clients may choose to wrap BaseBijectionClient for additional control.

Constructors

constructor

• new BijectionClient(address, options?) Construct a client and immediately initiate a WebSocket connection to the passed address.

Parameters

Accessors

closed

• get closed(): boolean Once closed no registered callbacks will fire again.

Returns

boolean

client

• get client(): BaseBijectionClient

Returns

BaseBijectionClient

disabled

• get disabled(): boolean

Returns

boolean

Methods

onUpdate

▸ onUpdate<Query>(query, args, callback, onError?): Unsubscribe<FunctionReturnType<Query>> Call a callback whenever a new result for a query is received. The callback will run soon after being registered if a result for the query is already in memory. The return value is an Unsubscribe object which is both a function an an object with properties. Both of the patterns below work with this object:

Type parameters

Parameters

Returns

Unsubscribe<FunctionReturnType<Query>> an Unsubscribe function to stop calling the onUpdate function.

onPaginatedUpdate_experimental

▸ onPaginatedUpdate_experimental<Query>(query, args, options, callback, onError?): Unsubscribe<PaginatedQueryResult<FunctionReturnType<Query>[]>> Call a callback whenever a new result for a paginated query is received. This is an experimental preview: the final API may change. In particular, caching behavior, page splitting, and required paginated query options may change.

Type parameters

Parameters

Returns

Unsubscribe<PaginatedQueryResult<FunctionReturnType<Query>[]>> an Unsubscribe function to stop calling the callback.

close

▸ close(): Promise<void>

Returns

Promise<void>

getAuth

▸ getAuth(): undefined | { token: string ; decoded: Record<string, any> } Get the current JWT auth token and decoded claims.

Returns

undefined | { token: string ; decoded: Record<string, any> }

setAuth

▸ setAuth(fetchToken, onChange?): void Set the authentication token to be used for subsequent queries and mutations. fetchToken will be called automatically again if a token expires. fetchToken should return null if the token cannot be retrieved, for example when the user’s rights were permanently revoked.

Parameters

Returns

void

mutation

▸ mutation<Mutation>(mutation, args, options?): Promise<Awaited<FunctionReturnType<Mutation>>> Execute a mutation function.

Type parameters

Parameters

Returns

Promise<Awaited<FunctionReturnType<Mutation>>> A promise of the mutation’s result.

action

▸ action<Action>(action, args): Promise<Awaited<FunctionReturnType<Action>>> Execute an action function.

Type parameters

Parameters

Returns

Promise<Awaited<FunctionReturnType<Action>>> A promise of the action’s result.

query

▸ query<Query>(query, args): Promise<Awaited<FunctionReturnType<Query>>> Fetch a query result once.

Type parameters

Parameters

Returns

Promise<Awaited<FunctionReturnType<Query>>> A promise of the query’s result.

connectionState

▸ connectionState(): ConnectionState Get the current ConnectionState between the client and the Bijection backend.

Returns

ConnectionState The ConnectionState with the Bijection backend.

subscribeToConnectionState

▸ subscribeToConnectionState(cb): () => void Subscribe to the ConnectionState between the client and the Bijection backend, calling a callback each time it changes. Subscribed callbacks will be called when any part of ConnectionState changes. ConnectionState may grow in future versions (e.g. to provide a array of inflight requests) in which case callbacks would be called more frequently.

Parameters

Returns

fn An unsubscribe function to stop listening. ▸ (): void Subscribe to the ConnectionState between the client and the Bijection backend, calling a callback each time it changes. Subscribed callbacks will be called when any part of ConnectionState changes. ConnectionState may grow in future versions (e.g. to provide a array of inflight requests) in which case callbacks would be called more frequently.
Returns
void An unsubscribe function to stop listening.