crelte / queries / Queries
Class: Queries
With queries you can execute GraphQl queries, either directly to the endpoint or via the server queries.
By default if you import a graphql file it will be called via the server queries.
Methods
query()
ts
query(
query,
vars,
opts): Promise<unknown>;Run a GraphQl Query
Parameters
query
the default export from a graphql file or the gqlquery {} function
vars
Record<string, unknown> = {}
variables that should be passed to the graphql query
opts
QueryOptions = {}
Returns
Promise<unknown>
new()
ts
static new(
endpoint,
frontend,
ssrCache,
opts): Queries;Create a new Queries instance
Parameters
endpoint
string
the craft GraphQl endpoint
frontend
the frontend url where the server queries are reachable
string | null
ssrCache
SsrCache = ...
the ssrCache to use for caching
opts
QueriesOptions = {}
options
Returns
Queries
newExternal()
ts
static newExternal(endpoint, bearerToken?): Queries;Create a new Queries instance that always intented to call an external GraphQl endpoint.
Parameters
endpoint
string
bearerToken?
string
Returns
Queries