Install brX GraphQL Service
Introduction
Goal
Install the brX GraphQL Service and connect it to the Commerce Backend Platform.
Background
The brX GraphQL Service is designed as an out-of-the-box GraphQL Server to integrate with the Commerce Backend Platform and Bloomreach Discovery.
This page explains how to set up the brX GraphQL Service in your environment.
Create Environment File
The brX GraphQL Service requires an environment configuration file named ".env" in the project root folder. This environment configuration file contains the connection information to the Commerce Backend Platform and other configuration options. Therefore, you should edit the file with correct information to make it work. See Configure brX GraphQL Service for details.
Create your project folder - e.g. brx-graphql-service - move to that directory and create the ".env" file: for now, you can just copy the content from snippet below to the .env file.
npm_package_name=brx-graphql-service-app npm_package_version=0.0.1 NODE_ENV=production DEBUG_TRACE_PAYLOAD=false PORT=4000 APOLLO_INTROSPECTION=true APOLLO_PLAYGROUND=true LOG_LEVEL=info TOKEN_TIMEOUT=3600 TOKEN_REFRESH_ENABLED=false DEFAULT_CONNECTOR_ID=brsm BRSM_API=http://core.dxpapi.com/api BRSM_SUGGESTION_API=https://suggest.dxpapi.com/api BRSM_ACCOUNT_ID= BRSM_DOMAIN_KEY= BRSM_AUTH_KEY= JWK_KEYSTORE={"keys":[{"kty":"oct","kid":"sample_key_id","k":"changeme"}]}
Install and Run the brX GraphQL Service
In the project folder - e.g. brx-graphql-service created as part of the previous paragraph - execute the following command:
npm init -y
This command will produce a package.json file with the standard configurations.
Install the GraphQL Service dependency:
npm install @bloomreach/graphql-commerce-connector-service
Create a sample index.js file, that just includes the graphql-service dependency:
echo "const graphqlService = require(\"@bloomreach/graphql-commerce-connector-service\");" > index.js
From the root project folder - where both the index.js and .env are located - execute the following command:
node --require dotenv/config index.js
If you see a log like "🚀 Server (brx-graphql-service-app:0.0.1 ... ready at port ..." without any error, then the server is ready to serve.