Configure urql client with options under urql key of nuxt config.
endpointThe absolute URL to connect to the graphql API.
export default defineNuxtConfig({
urql: {
endpoint: "http://...",
},
});
client [object]Small subset of urql client options.
client.requestPolicyThe default request policy for requests.
client.preferGetMethodUse HTTP GET for queries.
client [string]urql.configPath to the file (.json,.js,.ts) to configure client (fetch options, exchanges, ...).
Use the defineUrqlClient helper as the default export to return ClientOptions
import { fetchExchange } from "@urql/core";
import { cacheExchange } from "@urql/exchange-graphcache";
import { defineUrqlClient } from "#urql/client";
// use urql graphcache
const cacheConfig: GraphCacheConfig = {
schema,
keys: {
// ...
},
resolvers: {
// ...
},
};
export default defineUrqlClient((ssrExchange) => {
const exchanges = process.server
? [ssrExchange, fetchExchange]
: [cacheExchange(cacheConfig), ssrExchange, fetchExchange];
const headers = useRequestHeaders(["cookie", "authorization"]);
return {
exchanges,
fetchOptions: () => ({ headers }),
};
});
ssrOptions relative to the SSR exchange.
For more information go to urql server side rendering page.
ssr.key__URQL_DATA__Key name used by the SSR exchange to send its data in nuxt payload.
ssr.staleWhileRevalidateUpdate data immediately after rehydration.
ssr.includeExtensionsInclude graphql extensions in payload.