Skip to content

Commit 78287d8

Browse files
committed
initial storefront graphql reference docs
1 parent 1894a1b commit 78287d8

4 files changed

Lines changed: 17 additions & 21 deletions

File tree

content/docs/storefront/graphql/index.mdx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,3 @@ Handle customer registration and authentication directly from your storefront wi
136136
### Vouchers and discounts
137137

138138
Apply and remove voucher codes from carts using `addVoucher` and `removeVoucher` mutations, enabling custom promo code UIs.
139-
140-
141-

content/docs/storefront/graphql/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "GraphQL API",
2+
"title": "Storefront GraphQL API",
33
"pages": [
44
"queries",
55
"mutations"

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/types/routes.d.ts";
3+
import "./.next/dev/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

scripts/generate-graphql-docs.mjs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ const LINK_ROOT = '/docs/storefront/graphql';
2323

2424
// ── Step 1: Clean & generate ────────────────────────────────────────────────
2525

26+
// Preserve hand-written files (index.mdx, meta.json) during regeneration
27+
const preserveFiles = ['index.mdx', 'meta.json'];
28+
const preserved = {};
29+
for (const file of preserveFiles) {
30+
const p = join(GRAPHQL_DIR, file);
31+
if (existsSync(p)) {
32+
preserved[file] = readFileSync(p, 'utf8');
33+
}
34+
}
35+
2636
if (existsSync(GRAPHQL_DIR)) {
2737
rmSync(GRAPHQL_DIR, { recursive: true });
2838
}
@@ -51,25 +61,14 @@ for (const dir of ['operations', 'types']) {
5161
if (existsSync(p)) rmSync(p, { recursive: true });
5262
}
5363

54-
// Remove the generated landing page
64+
// Remove the generated landing page (we maintain a custom index.mdx)
5565
const generatedPath = join(GRAPHQL_DIR, 'generated.md');
5666
if (existsSync(generatedPath)) rmSync(generatedPath);
5767

58-
// Write clean index
59-
const indexPath = join(GRAPHQL_DIR, 'index.md');
60-
writeFileSync(indexPath, `---
61-
title: GraphQL Reference
62-
---
63-
64-
The Storefront GraphQL API reference documentation, automatically generated from the schema.
65-
66-
Browse all available [Queries](/docs/storefront/graphql/queries) and [Mutations](/docs/storefront/graphql/mutations).
67-
`);
68-
69-
writeFileSync(join(GRAPHQL_DIR, 'meta.json'), JSON.stringify({
70-
title: 'GraphQL Reference',
71-
pages: ['queries', 'mutations'],
72-
}, null, 2) + '\n');
68+
// Restore hand-written files that were preserved before the clean
69+
for (const [file, content] of Object.entries(preserved)) {
70+
writeFileSync(join(GRAPHQL_DIR, file), content);
71+
}
7372

7473
// ── Step 3: Introspect schema ───────────────────────────────────────────────
7574

0 commit comments

Comments
 (0)