Liking cljdoc? Tell your friends :D

artemis.core


Clientcljs

source

client?cljs

(client? x)

Returns true if x is a valid client.

Returns `true` if `x` is a valid client.
sourceraw docstring

create-clientcljs

(create-client &
               {:keys [store network-chain defaults]
                :or {store (mgs/create-store)
                     network-chain (http/create-network-step)}})

Returns a new Client specified by :store, :network-chain, and :defaults.

Returns a new `Client` specified by `:store`, `:network-chain`, and
`:defaults`.
sourceraw docstring

execcljs

(exec network-chain operation context)

Calls artemis.network-steps.protocols/-exec on a given network chain.

Calls `artemis.network-steps.protocols/-exec` on a given network chain.
sourceraw docstring

mutate!cljs

(mutate! client document)
(mutate! client document & args)

Given a client, document, and optional :variables and :options, returns a channel that will receive the response(s) for a mutation.

The :variables argument is a map of variables for the GraphQL mutation.

The :options argument is a map optionally including:

  • :out-chan The channel to put mutation messages onto. Defaults to (cljs.core.async/channel).
  • :context A map of context to pass along when executing the network chain. Defaults to {}.
  • :before-write A function that gets called before a mutation is written to the client's store. Will get called with a map containing the current store, the result data, the mutation document, variables, and a boolean representing whether or not the write will be an optimistic write. Should return a result.
  • :after-write A function that gets called after a mutation is written to the client's store. Will get called with a map containing the updated store, the result data, the mutation document, variables, and a boolean representing whether or not the write was an optimistic write. Should return a store.
  • :optimistic-result A map describing an anticipated/optimistic result. The optimistic result will be put onto the channel before waiting for a successful mutation response.
Given a client, document, and optional `:variables` and `:options`, returns
a channel that will receive the response(s) for a mutation.

The `:variables` argument is a map of variables for the GraphQL mutation.

The `:options` argument is a map optionally including:

- `:out-chan`          The channel to put mutation messages onto. Defaults to
                       `(cljs.core.async/channel)`.
- `:context`           A map of context to pass along when executing the
                       network chain. Defaults to `{}`.
- `:before-write`      A function that gets called before a mutation is
                       written to the client's store. Will get called with a
                       map containing the current store, the result data, the
                       mutation document, variables, and a boolean
                       representing whether or not the write will be an
                       optimistic write. Should return a result.
- `:after-write`       A function that gets called after a mutation is
                       written to the client's store. Will get called with
                       a map containing the updated store, the result data,
                       the mutation document, variables, and a boolean
                       representing whether or not the write was an
                       optimistic write. Should return a store.
- `:optimistic-result` A map describing an anticipated/optimistic result.
                       The optimistic result will be put onto the channel
                       before waiting for a successful mutation response.
sourceraw docstring

network-chaincljs

(network-chain client)

Returns the client's network chain. Returns nil if no network chain exists for the client.

Returns the client's network chain. Returns `nil` if no network chain exists
for the client.
sourceraw docstring

query!cljs

(query! client document)
(query! client document & args)

Given a client, document, and optional :variables and :options, returns a channel that will receive the response(s) for a query. Depending on the :fetch-policy option, the channel will receive one or more messages.

The :variables argument is a map of variables for the GraphQL query.

The :options argument is a map optionally including:

  • :out-chan The channel to put query messages onto. Defaults to (cljs.core.async/channel).
  • :context A map of context to pass along when executing the network chain. Defaults to {}.
  • :fetch-policy A keyword specifying the fetch policy (see below). Defaults to the configured default or :local-only.

The available fetch policies and corresponding implications are:

:no-cache

A query will never be read or write to the local store. Instead, it will always execute a remote query without caching the result. This policy is for when you want data coming directly from the remote source and don't intend for the result to ever be used by other queries.

:local-only

A query will never be executed remotely. Instead, the query will only run against the local store. If the query can't be satisfied locally, an error message will be put on the return channel. This fetch policy allows you to only interact with data in your local store without making any network requests which keeps your component fast, but means your local data might not be consistent with what is on the server. For this reason, this policy should only be used on data that is highly unlikely to change, or is regularly being refreshed.

:local-first

Will run a query against the local store first. The result of the local query will be put on the return channel. If that result is a non-nil value, then a remote query will not be executed. If the result is nil, meaning the data isn't available locally, a remote query will be executed. This fetch policy aims to minimize the number of network requests sent. The same cautions around stale data that applied to the :local-only policy do so for this policy as well.

:local-then-remote

Like the :local-first policy, this will run a query against the local store first and put the result on the return channel. However, unlike :local-first, a remote query will always be executed regardless of the value of the local result. This fetch policy optimizes for users getting a quick response while also trying to keep cached data consistent with your remote data at the cost of extra network requests.

:remote-only

This fetch policy will never run against the local store. Instead, it will always execute a remote query. This policy optimizes for data consistency with the server, but at the cost of an instant response.

Given a client, document, and optional `:variables` and `:options`, returns
a channel that will receive the response(s) for a query. Depending on the
`:fetch-policy` option, the channel will receive one or more messages.

The `:variables` argument is a map of variables for the GraphQL query.

The `:options` argument is a map optionally including:

- `:out-chan`     The channel to put query messages onto. Defaults to
                  `(cljs.core.async/channel)`.
- `:context`      A map of context to pass along when executing the network
                  chain. Defaults to `{}`.
- `:fetch-policy` A keyword specifying the fetch policy _(see below)_.
                  Defaults to the configured default or `:local-only`.

The available fetch policies and corresponding implications are:

#### `:no-cache`
A query will never be read or write to the local store. Instead, it will
always execute a remote query without caching the result. This policy
is for when you want data coming directly from the remote source and don't
intend for the result to ever be used by other queries.

#### `:local-only`
A query will never be executed remotely. Instead, the query will only run
against the local store. If the query can't be satisfied locally, an error
message will be put on the return channel. This fetch policy allows you to
only interact with data in your local store without making any network
requests which keeps your component fast, but means your local data might not
be consistent with what is on the server. For this reason, this policy should
only be used on data that is highly unlikely to change, or is regularly being
refreshed.

#### `:local-first`
Will run a query against the local store first. The result of the local query
will be put on the return channel. If that result is a non-nil value, then a
remote query will not be executed. If the result is `nil`, meaning the data
isn't available locally, a remote query will be executed. This fetch policy
aims to minimize the number of network requests sent. The same cautions
around stale data that applied to the `:local-only` policy do so for this
policy as well.

#### `:local-then-remote`
Like the `:local-first` policy, this will run a query against the local store
first and put the result on the return channel.  However, unlike
`:local-first`, a remote query will always be executed regardless of the
value of the local result. This fetch policy optimizes for users getting a
quick response while also trying to keep cached data consistent with your
remote data at the cost of extra network requests.

#### `:remote-only`
This fetch policy will never run against the local store.  Instead, it will
always execute a remote query. This policy optimizes for data consistency
with the server, but at the cost of an instant response.
sourceraw docstring

readcljs

(read store
      document
      variables
      &
      {:keys [return-partial?] :or {return-partial? false}})

Calls artemis.stores.protocols/-read on a given store.

Calls `artemis.stores.protocols/-read` on a given store.
sourceraw docstring

read-fragmentcljs

(read-fragment store
               document
               entity-ref
               &
               {:keys [return-partial?] :or {return-partial? false}})

Calls artemis.stores.protocols/-read-fragment on a given store.

Calls `artemis.stores.protocols/-read-fragment` on a given store.
sourceraw docstring

storecljs

(store client)

Returns the client's store. Returns nil if no store exists for the client.

Returns the client's store. Returns `nil` if no store exists for the
client.
sourceraw docstring

subscribe!cljs

(subscribe! client document)
(subscribe! client document & args)

Given a client, document, and optional :variables and :options, establishes a GraphQL subscription over a WebSocket connection, returning a channel that will receive a stream of updates from the server. Note that GraphQL subscriptions only listen for updates from the server, they don't request any data and so won't receive any when the connection is established. If you need an initial set of data, combine subscribe! with query!, setting an appropriate :fetch-policy.

The :variables argument is a map of variables for the GraphQL subscription.

The :options argument is a map optionally including:

  • :out-chan The channel to put subscription update messages onto. Defaults to (cljs.core.async/channel).
  • :ws-id A unique ID for the subscription. Can be used to unsubscribe from updates. Defaults to a generated unique ID.
  • :context A map of context to pass along when executing the network chain. Defaults to {}.
Given a client, document, and optional `:variables` and `:options`,
establishes a GraphQL subscription over a WebSocket connection, returning a
channel that will receive a stream of updates from the server. Note that
GraphQL subscriptions only listen for updates from the server, they don't
request any data and so won't receive any when the connection is established.
If you need an initial set of data, combine `subscribe!` with `query!`,
setting an appropriate `:fetch-policy`.

The `:variables` argument is a map of variables for the GraphQL subscription.

The `:options` argument is a map optionally including:

- `:out-chan`          The channel to put subscription update messages onto.
                       Defaults to `(cljs.core.async/channel)`.
- `:ws-id`             A unique ID for the subscription. Can be used to
                       unsubscribe from updates. Defaults to a generated
                       unique ID.
- `:context`           A map of context to pass along when executing the
                       network chain. Defaults to `{}`. 
sourceraw docstring

watch-storecljs

(watch-store client watch-cb)

Given a client and a callback, will call the callback whenever there's a change to the client's store with the old store state and the new store state as arguments. Returns an unwatch function.

Given a client and a callback, will call the callback whenever there's a
change to the client's store with the old store state and the new store
state as arguments. Returns an unwatch function.
sourceraw docstring

writecljs

(write store data document variables)

Calls artemis.stores.protocols/-write on a given store.

Calls `artemis.stores.protocols/-write` on a given store.
sourceraw docstring

write-fragmentcljs

(write-fragment store data document entity-ref)

Calls artemis.stores.protocols/-write-fragment on a given store.

Calls `artemis.stores.protocols/-write-fragment` on a given store.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close