<h1 align="center"> Synerise Faststore API </h1>
npm install @synerise/faststore-apiFrom the command line in your project directory, run yarn add @synerise/faststore-api.
``cmd`
yarn add @synerise/faststore-api
`ts
// src/graphql/thirdParty/resolvers/index.ts
import { Resolvers as SyneriseResolvers } from "@synerise/faststore-api";
const resolvers = {
...SyneriseResolvers,
};
export default resolvers;
`
After adding the resolvers, ensure you copy the files from the typeDefs folder to your project'ssrc/graphql/thirdParty/typeDefs folder. This step is required to integrate the schema definitions properly.
This approach allows you to directly integrate pre-defined resolvers into your application, making it easier to set up
and use the provided functionalities.
#### Required Environment Variables
You can use the provided resolvers by either adding the following environment variables to your vtex.env file:
`env`
SYNERISE_API_URL=https://api.synerise.com
SYNERISE_API_TRACKER=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
SYNERISE_SEARCH_INDEX=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
or by specifying indexId, apiHost, and trackerKey directly in your GraphQL queries:
`graphql`
query SyneriseSearchQuery(
$apiHost: String,
$trackerKey: String,
$indexId: String,
$query: String!
) {
syneriseAISearch(indexId: $indexId, apiHost: $apiHost, trackerKey: $trackerKey) {
search(
query: $query,
) {
...
}
}
}
These variables are necessary for proper configuration and communication with the Synerise API.
Alternatively, you can import and configure a specific client for more granular control:
`ts
import { SyneriseSearchClient } from '@synerise/faststore-api';
const searchClient = new SyneriseSearchClient({
host: "https://api.synerise.com",
trackerKey: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
indexId: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
});
// Use the search client as needed
``
This method is suitable when you need to work with a specific service or API client, allowing you to customize the
configuration and use only the functionalities you need.