Vue Storefront is now Alokai! Learn More
Legacy GraphQL API

Legacy GraphQL API

Deprecated

The legacy GraphQL API is maintained for backward compatibility only. We strongly recommend migrating to the new REST API-based integration, which provides better performance, type safety, and access to all modern Bloomreach Discovery features.

Overview

The legacy extension provides access to the original Bloomreach Discovery GraphQL Commerce API. This extension is available for existing customers who need time to migrate their applications, but new projects should use the modern REST API endpoints instead.

When to Use

Use the legacy extension only if:

  • You have an existing integration using the GraphQL API
  • You're in the process of migrating to the new API
  • You have custom queries that haven't been migrated yet

Configuration

To enable the legacy extension, add the optional legacy configuration to your middleware integration:

// apps/storefront-middleware/integrations/bloomreach-discovery/config.ts
import type { ApiClientExtension, Integration } from '@alokai/connect/middleware';
import type { MiddlewareConfig } from '@vsf-enterprise/bloomreach-discovery-api';

const {
  BLOOMREACH_DISCOVERY_ACCOUNT_ID,
  BLOOMREACH_DISCOVERY_AUTH_KEY,
  BLOOMREACH_DISCOVERY_DOMAIN_KEY,
  // Legacy API environment variables
  BLOOMREACH_LEGACY_ENDPOINT,
  BLOOMREACH_LEGACY_ENV_ID,
} = process.env;

if (!BLOOMREACH_DISCOVERY_ACCOUNT_ID)
  throw new Error('Missing env var: BLOOMREACH_DISCOVERY_ACCOUNT_ID');
if (!BLOOMREACH_DISCOVERY_DOMAIN_KEY)
  throw new Error('Missing env var: BLOOMREACH_DISCOVERY_DOMAIN_KEY');

export const config = {
  configuration: {
    discoveryApi: {
      accountId: Number(BLOOMREACH_DISCOVERY_ACCOUNT_ID),
      authKey: BLOOMREACH_DISCOVERY_AUTH_KEY,
      domainKey: BLOOMREACH_DISCOVERY_DOMAIN_KEY,
      facetVersion: '3.0',
    },
    // Optional: Legacy API configuration
    legacy: BLOOMREACH_LEGACY_ENDPOINT && BLOOMREACH_LEGACY_ENV_ID ? {
      endpoint: BLOOMREACH_LEGACY_ENDPOINT,
      envId: BLOOMREACH_LEGACY_ENV_ID,
    } : undefined,
  },
  extensions: (existing: ApiClientExtension[]) => [...existing],
  location: '@vsf-enterprise/bloomreach-discovery-api/server',
} satisfies Integration<Config>;

export type Config = MiddlewareConfig;

Environment Variables

Add the following to your .env file:

# Legacy GraphQL API (optional)
BLOOMREACH_LEGACY_ENDPOINT=https://your-graphql-endpoint.bloomreach.io/graphql
BLOOMREACH_LEGACY_ENV_ID=your_environment_id

SDK Usage

Using Legacy SDK Package

Alternatively, you can use the legacy @vsf-enterprise/bloomreach-discovery-sdk package:

// storefront-unified-nextjs/sdk/modules/bloomreach-discovery-legacy.ts
import { defineSdkModule } from '@vue-storefront/next';
import { bloomreachDiscoveryModule } from '@vsf-enterprise/bloomreach-discovery-sdk';

export const bloomreachDiscoveryLegacy = defineSdkModule(({ buildModule, config }) =>
  buildModule(bloomreachDiscoveryModule, {
    apiUrl: `${config.apiUrl}/bloomreach-discovery/legacy`,
    ssrApiUrl: `${config.ssrApiUrl}/bloomreach-discovery/legacy`,
  }),
);

Then use the predefined methods:

const sdk = getSdk();

// Using legacy SDK methods
const data = await sdk.bloomreachDiscoveryLegacy.findItemsByKeyword({
  text: 'running shoes',
  expect: `items { displayName, price }`,
});

Migration Path

We recommend migrating to the new REST API for the following benefits:

Advantages of the New API

  • Better Performance: Direct REST API calls are faster than GraphQL
  • Full Type Safety: Generated TypeScript types from OpenAPI specs
  • Modern Features: Access to latest Bloomreach Discovery capabilities
  • Simpler Integration: No need to write GraphQL queries
  • Better Documentation: Official Bloomreach REST API documentation
  • Facet Version 3.0: Enhanced faceting and filtering capabilities

Migration Steps

  1. Start with new endpoints: Use the new REST API for any new features
  2. Gradual migration: Replace legacy calls one at a time
  3. Test thoroughly: Ensure feature parity with legacy implementation
  4. Remove legacy config: Once fully migrated, remove the legacy configuration