Skip to main content
Version: next

Axios instances

This reference explains how to access `axios` instances to interact with Gezy's API.

Overview

The Front-Commerce's Gezy extension exposes preconfigured HTTP client instances for interacting with Gezy's API. These instances are exposed via the Dependency Injection system, under the gezy HTTP namespace.

You can access them via services.DI.get("gezy").http.* in your code.

publicRestAPI

The publicRestAPI instance is an axios instance that can be used to interact with Gezy's API as a customer.
It will sign requests depending on the current user's session.

Example:

path/to/graphql/module/runtime.ts
import { createGraphQLRuntime } from "@front-commerce/core/graphql";

export default createGraphQLRuntime({
contextEnhancer: ({ services, makeDataLoader }) => {
const gezyClient = services.DI.get("gezy").http.publicRestAPI;

return {
MyFeature: new MyFeatureLoader(gezyClient, makeDataLoader),
};
},
});