This directory contains SpectaQL configuration files for generating the Merchandising GraphQL API reference as a static HTML page.
- Node.js matching the version in .nvmrc
- Yarn
| File | Role |
|---|---|
config-merchandising.yml |
Main SpectaQL config. Defines where to get the schema, what to document/hide, metadata paths, server info, intro text, theme, and the output directory (static/graphql-api/merchandising-api). |
metadata-merchandising.json |
Filtering and description metadata. Marks unwanted queries, types, enums, unions, input objects, and interfaces as undocumented: true so SpectaQL excludes them. Also contains custom descriptions for query arguments under FIELD_ARGUMENT. |
enhanced-schema.json |
Cached introspection result with custom descriptions already injected. Used for dev builds instead of hitting the live endpoint on every rebuild. Generated by scripts/fetch-and-enhance-schema.js. |
config-merchandising-temp.yml |
Auto-generated temp config. A copy of the main config with ${TENANT_ID} placeholders replaced by the actual environment variable value. Deleted automatically after the build. |
config-admin.yml |
Configuration for the Admin API (reference not currently implemented). |
comdox-theme/ |
Custom SpectaQL theme. Contains Handlebars partial overrides (type.hbs and _query-or-mutation-or-subscription.hbs) that customize how types and queries render in the HTML output. |
| Script | Role |
|---|---|
generate-spectaql-config.js |
Reads config-merchandising.yml, substitutes ${TENANT_ID} from your .env file, writes the temp config, and cleans up on exit. |
run-spectaql-with-cleanup.js |
Orchestrates the dev build: generates the temp config, switches it to use enhanced-schema.json, spawns SpectaQL as a child process, then cleans up the temp file. This is what yarn dev:merchandising-api runs. |
fetch-and-enhance-schema.js |
Fetches a live introspection result from the GraphQL endpoint, then injects custom descriptions from metadata-merchandising.json into the raw schema. Saves the result to enhanced-schema.json. |
build-with-enhanced-schema.js |
Orchestrates the production build: (1) fetches a fresh schema and injects descriptions from metadata-merchandising.json, (2) generates the temp config and rewrites it to point at enhanced-schema.json instead of the live URL, (3) runs SpectaQL. This is what yarn build:merchandising-api runs. |
| File | Role |
|---|---|
.env (root) |
Provides TENANT_ID and CATALOG_VIEW_ID needed to call the live GraphQL endpoint and substitute into the config. |
static/graphql-api/merchandising-api/index.html |
The final output. The generated HTML documentation page that gets committed and embedded in the documentation site. |
Set the following in a .env file in the project root:
cp .env.example .env| Variable | Description |
|---|---|
TENANT_ID |
Your Adobe Commerce tenant ID |
CATALOG_VIEW_ID |
Catalog view ID for the API context |
Both variables are required for any build that fetches the live schema.
The documentation is generated by SpectaQL, which turns a GraphQL schema into a static HTML API reference. The metadata-merchandising.json file does double duty: it both filters what appears (via undocumented: true markers) and provides custom descriptions (via the FIELD_ARGUMENT section and description fields on types/queries).
The metadata file includes only these queries:
attributeMetadatacategoryTreenavigationproductSearchproductsrecommendationsByUnitIdsrefineProductvariants
All other queries and their exclusively-referenced types are marked as undocumented and excluded from the generated output.
The metadata file uses SpectaQL's metadata format with these sections:
OBJECT.Query.fields— Marks unwanted queries asundocumented: trueOBJECT.*— Marks unwanted Object types asundocumented: trueINPUT_OBJECT.*— Marks unwanted Input types asundocumented: trueENUM.*— Marks unwanted Enum types asundocumented: trueUNION.*— Marks unwanted Union types asundocumented: trueINTERFACE.*— Marks unwanted Interface types asundocumented: trueFIELD_ARGUMENT— Provides custom descriptions for query arguments (e.g.,categoryTreeandnavigationarguments)
The config-merchandising.yml file supports two mutually exclusive schema sources under the introspection: section. Only one should be active at a time.
By default, the config uses the live GraphQL endpoint. This requires the TENANT_ID and CATALOG_VIEW_ID environment variables to be set in your .env file:
# introspectionFile: spectaql/enhanced-schema.json
url: https://na1-qa.api.commerce.adobe.com/${TENANT_ID}/graphqlTo generate documentation offline without hitting the live endpoint, comment out the url line and uncomment the introspectionFile line:
introspectionFile: spectaql/enhanced-schema.json
# url: https://na1-qa.api.commerce.adobe.com/${TENANT_ID}/graphqlThe static schema file (enhanced-schema.json) is a cached introspection result with custom descriptions already injected. You can update it at any time by running:
node scripts/fetch-and-enhance-schema.jsNote: Only one of
urlorintrospectionFileshould be uncommented. If both are active, SpectaQL will raise an error.
Both build paths produce static/graphql-api/merchandising-api/index.html.
Fetches a fresh schema from the live endpoint, injects all custom descriptions from metadata-merchandising.json, and runs SpectaQL:
yarn build:merchandising-apiWhat happens during a production build:
fetch-and-enhance-schema.jsfetches the live introspection result and injects descriptions frommetadata-merchandising.jsondirectly into the schema JSON.- The result is saved to
enhanced-schema.json. generate-spectaql-config.jsreads the YAML config, replaces${TENANT_ID}, and writes the temp config.- The temp config is rewritten to use
introspectionFile: spectaql/enhanced-schema.jsoninstead of the live URL. - SpectaQL runs against the local enhanced schema file.
- The custom theme partials override the default rendering.
- Output lands in
static/graphql-api/merchandising-api/index.html. - The temp config file is cleaned up.
Uses the existing enhanced-schema.json on disk — no live API call. Useful when iterating on metadata descriptions, theme templates, or config without waiting for a schema fetch:
yarn dev:merchandising-apiThis starts SpectaQL in watch mode with a live preview at http://localhost:4400. It rebuilds automatically when source files change.
Note: The dev build does not refresh
enhanced-schema.json. If the live schema has changed or you have updatedmetadata-merchandising.json, runyarn build:merchandising-apito get a fresh result.
To fetch and enhance the schema without running SpectaQL:
node scripts/fetch-and-enhance-schema.jsThis saves the result to enhanced-schema.json and is useful when you want to inspect the schema before building.
If the schema or metadata descriptions change, rebuild and test the API reference locally:
-
Create a branch from
main. -
Make your changes to
metadata-merchandising.json, theme templates, or config. -
Run the production build to regenerate the schema and documentation:
yarn build:merchandising-api
-
Open
static/graphql-api/merchandising-api/index.htmlin your browser and verify the output. -
Commit the updated
index.htmlandenhanced-schema.jsonfiles. -
After updates are approved, a documentation team member merges the PR and publishes the updates to the developer site.
The build generates static/graphql-api/merchandising-api/index.html, which is embedded in the documentation site using the Adobe I/O theme's frameSrc feature.
- The
${TENANT_ID}placeholder in the YAML config is processed byscripts/generate-spectaql-config.js, which creates a temporaryconfig-merchandising-temp.ymlfile - Temporary config files are automatically cleaned up after the build completes
- The
.envfile is in.gitignoreto prevent committing sensitive information - The Sass
@importdeprecation warnings during the build are cosmetic (from SpectaQL's internal stylesheets) and do not affect the output