You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Simplify build pipeline and remove dead script code
- Wire yarn build:merchandising-api to build-with-enhanced-schema.js so
the production build always fetches a fresh schema and injects descriptions
- Delete inject-descriptions.js (unused; logic lives in fetch-and-enhance-schema.js)
- Remove dead code in build-with-enhanced-schema.js (redundant require, unused export)
- Remove unused generateConfig variable in run-spectaql-with-cleanup.js
- Remove injectDescriptions from fetch-and-enhance-schema.js exports (not used externally)
- Update README.md and spectaql/README.md to reflect the simplified build workflow
- Rebuild index.html with latest enhanced schema
Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ If you have questions, open an issue and ask us. We look forward to hearing from
60
60
61
61
## GraphQL API reference generator
62
62
63
-
The Merchandising GraphQL API reference is generated using [SpectaQL](https://github.com/anvilco/spectaql). It uses live introspection against the GraphQL endpoint and a metadata overlay to filter the schema down to the documented queries and types.
63
+
The Merchandising GraphQL API reference is generated using [SpectaQL](https://github.com/anvilco/spectaql). It fetches the live schema via introspection, injects custom descriptions from a metadata overlay, and filters the schema down to the include only the queries and types supported by Adobe Commerce Optimizer catalog service operations.
64
64
65
65
### Quick start
66
66
@@ -90,10 +90,10 @@ To generate a live preview during local development, run: `yarn dev:merchandisin
90
90
If the schema or metadata descriptions change, rebuild and test the API reference locally:
91
91
92
92
1. Create a branch from `main`.
93
-
2. Regenerate the API reference using the enhanced build (includes custom descriptions):
Copy file name to clipboardExpand all lines: spectaql/README.md
+26-45Lines changed: 26 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ This directory contains [SpectaQL](https://github.com/anvilco/spectaql) configur
15
15
|---|---|
16
16
|`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`). |
17
17
|`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`. |
18
-
|`enhanced-schema.json`| Cached introspection result with custom descriptions already injected. Used for enhanced/offline builds instead of hitting the live endpoint. Generated by `scripts/fetch-and-enhance-schema.js`. |
18
+
|`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`. |
19
19
|`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. |
20
20
|`config-admin.yml`| Configuration for the Admin API (reference not currently implemented). |
21
21
|`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. |
@@ -25,10 +25,9 @@ This directory contains [SpectaQL](https://github.com/anvilco/spectaql) configur
25
25
| Script | Role |
26
26
|---|---|
27
27
|`generate-spectaql-config.js`| Reads `config-merchandising.yml`, substitutes `${TENANT_ID}` from your `.env` file, writes the temp config, and cleans up on exit. |
28
-
|`run-spectaql-with-cleanup.js`| Orchestrates the **standard build**: generates the temp config, spawns SpectaQL as a child process, then cleans up the temp file. This is what `yarn build:merchandising-api` runs. |
28
+
|`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. |
29
29
|`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`. |
30
-
|`inject-descriptions.js`| Standalone module with the same description-injection logic, packaged as a SpectaQL preprocessing function. |
31
-
|`build-with-enhanced-schema.js`| Orchestrates the **enhanced build**: (1) fetches and enhances the schema, (2) generates the temp config and rewrites it to point at `enhanced-schema.json` instead of the live URL, (3) runs SpectaQL. |
30
+
|`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. |
There are two build paths. Both produce `static/graphql-api/merchandising-api/index.html`.
117
+
Both build paths produce `static/graphql-api/merchandising-api/index.html`.
119
118
120
-
### Standard build (live endpoint)
119
+
### Production build
121
120
122
-
Uses live introspection to fetch the schema and applies metadata filtering:
121
+
Fetches a fresh schema from the live endpoint, injects all custom descriptions from `metadata-merchandising.json`, and runs SpectaQL:
123
122
124
123
```bash
125
124
yarn build:merchandising-api
126
-
127
-
# Or run in development mode with live preview
128
-
yarn dev:merchandising-api
129
125
```
130
126
131
-
What happens during a standard build:
127
+
What happens during a production build:
132
128
133
-
1. `generate-spectaql-config.js` reads the YAML config, replaces `${TENANT_ID}`, and writes the temp config
134
-
1. `run-spectaql-with-cleanup.js` spawns SpectaQL with the temp config.
135
-
1. SpectaQL introspects the live GraphQL endpoint.
136
-
1. SpectaQL applies `metadata-merchandising.json` to filter out unwanted queries/types and inject descriptions via its built-in metadata system
129
+
1. `fetch-and-enhance-schema.js` fetches the live introspection result and injects descriptions from `metadata-merchandising.json` directly into the schema JSON.
130
+
1. The result is saved to `enhanced-schema.json`.
131
+
1. `generate-spectaql-config.js` reads the YAML config, replaces `${TENANT_ID}`, and writes the temp config.
132
+
1. The temp config is rewritten to use `introspectionFile: spectaql/enhanced-schema.json` instead of the live URL.
133
+
1. SpectaQL runs against the local enhanced schema file.
137
134
1. The custom theme partials override the default rendering.
138
135
1. Output lands in `static/graphql-api/merchandising-api/index.html`.
139
136
1. The temp config file is cleaned up.
140
137
141
-
### Enhanced build (with description injection)
138
+
### Dev build (fast iteration)
142
139
143
-
The standard build uses the live schema as-is, so any query arguments that lack descriptions in the live schema appear blank. The enhanced build solves this by fetching the live schema, injecting the custom descriptions defined in `metadata-merchandising.json` (especially `FIELD_ARGUMENT` entries), and then running SpectaQL against the enhanced schema.
140
+
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:
144
141
145
142
```bash
146
-
node scripts/build-with-enhanced-schema.js
147
-
```
148
-
149
-
You can also pass extra SpectaQL flags, for example:
If you omit all arguments, it defaults to `--target-file index.html --config spectaql/config-merchandising-temp.yml`.
146
+
This starts SpectaQL in watch mode with a live preview at `http://localhost:4400`. It rebuilds automatically when source files change.
156
147
157
-
What happens during an enhanced build:
158
-
159
-
1. `fetch-and-enhance-schema.js` fetches the live introspection result and injects `FIELD_ARGUMENT` descriptions directly into the schema JSON
160
-
1. The result is saved to `enhanced-schema.json`.
161
-
1. The temp config is generated and rewritten to use `introspectionFile: spectaql/enhanced-schema.json` instead of the live URL.
162
-
1. SpectaQL runs against the local enhanced schema file.
163
-
1. Output lands in `static/graphql-api/merchandising-api/index.html`.
164
-
1. The temp config file is cleaned up.
165
-
166
-
Use the enhanced build whenever `metadata-merchandising.json` includes custom descriptions that you want reflected in the generated API reference.
148
+
> **Note:** The dev build does not refresh `enhanced-schema.json`. If the live schema has changed or you have updated `metadata-merchandising.json`, run `yarn build:merchandising-api` to get a fresh result.
167
149
168
150
### Update the cached schema only
169
151
@@ -173,24 +155,23 @@ To fetch and enhance the schema without running SpectaQL:
173
155
node scripts/fetch-and-enhance-schema.js
174
156
```
175
157
176
-
This saves the result to `enhanced-schema.json`. To use it for offline builds, the config already points to this file via `introspectionFile: spectaql/enhanced-schema.json`.
158
+
This saves the result to `enhanced-schema.json` and is useful when you want to inspect the schema before building.
177
159
178
160
## Update the API reference
179
161
180
162
If the schema or metadata descriptions change, rebuild and test the API reference locally:
181
163
182
164
1. Create a branch from `main`.
183
-
2. If you updated custom descriptions in `metadata-merchandising.json`, use the enhanced build:
184
-
185
-
```bash
186
-
node scripts/build-with-enhanced-schema.js
187
-
```
165
+
1. Make your changes to `metadata-merchandising.json`, theme templates, or config.
166
+
1. Run the production build to regenerate the schema and documentation:
188
167
189
-
Otherwise, use the standard build: `yarn build:merchandising-api`
168
+
```bash
169
+
yarn build:merchandising-api
170
+
```
190
171
191
-
3. Open `static/graphql-api/merchandising-api/index.html` in your browser and verify the output.
192
-
4. Commit the updated `index.html` and `enhanced-schema.json` files.
193
-
5. After updates are approved, a documentation team member merges the PR and publishes the updates to the [developer site](https://developer.adobe.com/commerce/services/merchandising-services/).
172
+
1. Open `static/graphql-api/merchandising-api/index.html` in your browser and verify the output.
173
+
1. Commit the updated `index.html` and `enhanced-schema.json` files.
174
+
1. After updates are approved, a documentation team member merges the PR and publishes the updates to the [developer site](https://developer.adobe.com/commerce/services/merchandising-services/).
0 commit comments