decoupled-cli 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -11
- package/dist/commands/auth.js +16 -6
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/content.js +3 -3
- package/dist/commands/content.js.map +1 -1
- package/dist/commands/download.js +3 -3
- package/dist/commands/spaces.d.ts.map +1 -1
- package/dist/commands/spaces.js +29 -28
- package/dist/commands/spaces.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/api.d.ts +1 -0
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +8 -3
- package/dist/lib/config.js.map +1 -1
- package/examples/.cursorrules +31 -31
- package/examples/CLAUDE.md +85 -85
- package/examples/GEMINI.md +82 -82
- package/examples/content-import-sample.json +237 -62
- package/package.json +3 -3
- package/dist/commands/tokens.d.ts +0 -3
- package/dist/commands/tokens.d.ts.map +0 -1
- package/dist/commands/tokens.js +0 -90
- package/dist/commands/tokens.js.map +0 -1
package/examples/GEMINI.md
CHANGED
|
@@ -5,7 +5,7 @@ This document provides Gemini with comprehensive instructions for building compl
|
|
|
5
5
|
## Project Overview
|
|
6
6
|
|
|
7
7
|
**Architecture**: Headless Drupal backend with Next.js frontend
|
|
8
|
-
**Backend**: Drupal 11 with GraphQL Compose and
|
|
8
|
+
**Backend**: Drupal 11 with GraphQL Compose and DC Import API
|
|
9
9
|
**Frontend**: Next.js 15 with TypeScript, Tailwind CSS, and Apollo GraphQL
|
|
10
10
|
**Environment**: DDEV local development
|
|
11
11
|
|
|
@@ -18,29 +18,29 @@ This document provides Gemini with comprehensive instructions for building compl
|
|
|
18
18
|
- `DRUPAL_REVALIDATE_SECRET` - Secret for on-demand revalidation
|
|
19
19
|
- `NODE_TLS_REJECT_UNAUTHORIZED=0` - Allow self-signed certificates (development)
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## DC CLI Setup
|
|
22
22
|
|
|
23
23
|
**First-time CLI setup:**
|
|
24
24
|
```bash
|
|
25
|
-
# 1. Install
|
|
26
|
-
npm install --save-dev
|
|
25
|
+
# 1. Install decoupled-cli locally (if not already present in package.json)
|
|
26
|
+
npm install --save-dev decoupled-cli
|
|
27
27
|
|
|
28
28
|
# 2. Configure authentication - you have two options:
|
|
29
29
|
|
|
30
30
|
# Option A: Use OAuth with your existing Drupal credentials (recommended for local development)
|
|
31
|
-
npx
|
|
31
|
+
npx decoupled-cli auth oauth
|
|
32
32
|
|
|
33
33
|
# Option B: Use personal access token (for production/remote deployments)
|
|
34
|
-
npx
|
|
34
|
+
npx decoupled-cli auth login
|
|
35
35
|
|
|
36
36
|
# 3. Set your default space for content imports (optional but recommended)
|
|
37
|
-
npx
|
|
37
|
+
npx decoupled-cli spaces use <space_id>
|
|
38
38
|
|
|
39
39
|
# 4. Verify authentication and space setup
|
|
40
|
-
npx
|
|
40
|
+
npx decoupled-cli spaces current
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
**OAuth Prerequisites (for `
|
|
43
|
+
**OAuth Prerequisites (for `decoupled-cli auth oauth`):**
|
|
44
44
|
Your `.env.local` must contain:
|
|
45
45
|
- `NEXT_PUBLIC_DRUPAL_BASE_URL=https://your-space.decoupled.io`
|
|
46
46
|
- `DRUPAL_CLIENT_ID=your_oauth_client_id`
|
|
@@ -48,12 +48,12 @@ Your `.env.local` must contain:
|
|
|
48
48
|
|
|
49
49
|
**Authentication Method Differences:**
|
|
50
50
|
- **OAuth** → Works with your Drupal site API (content import, Drupal operations)
|
|
51
|
-
- **Personal Access Token** → Works with
|
|
51
|
+
- **Personal Access Token** → Works with Decoupled Drupal platform API (spaces, users, organizations)
|
|
52
52
|
|
|
53
53
|
**If CLI is not available locally:**
|
|
54
|
-
- For projects with
|
|
55
|
-
- For development: `cd cli && npm install && npm run build && npm link` then use `
|
|
56
|
-
- Always prefer using `npx
|
|
54
|
+
- For projects with decoupled-cli in package.json: Run `npm install` then use `npx decoupled-cli`
|
|
55
|
+
- For development: `cd cli && npm install && npm run build && npm link` then use `decoupled-cli`
|
|
56
|
+
- Always prefer using `npx decoupled-cli` for consistency and local package management
|
|
57
57
|
|
|
58
58
|
## End-to-End Development Workflow
|
|
59
59
|
|
|
@@ -73,9 +73,9 @@ Use OAuth authentication for direct Drupal content import, then frontend develop
|
|
|
73
73
|
|
|
74
74
|
**Create a todo list for tracking progress:**
|
|
75
75
|
```markdown
|
|
76
|
-
1. Verify
|
|
77
|
-
2. Create
|
|
78
|
-
3. Import content type and sample content to Drupal (npx
|
|
76
|
+
1. Verify DC CLI authentication (npx decoupled-cli auth status)
|
|
77
|
+
2. Create DC Import JSON for [content_type]
|
|
78
|
+
3. Import content type and sample content to Drupal (npx decoupled-cli content import)
|
|
79
79
|
4. **CRITICAL**: Run schema generation (`npm run generate-schema`) to update GraphQL schema
|
|
80
80
|
5. Create TypeScript types and GraphQL queries
|
|
81
81
|
6. Build frontend components ([ContentCard], [ContentRenderer])
|
|
@@ -84,12 +84,12 @@ Use OAuth authentication for direct Drupal content import, then frontend develop
|
|
|
84
84
|
9. Validate end-to-end functionality
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
**Legacy Platform Workflow (PAT +
|
|
87
|
+
**Legacy Platform Workflow (PAT + Decoupled Drupal Platform):**
|
|
88
88
|
```markdown
|
|
89
|
-
1. Verify
|
|
90
|
-
2. Set default space if needed (npx
|
|
91
|
-
3. Create
|
|
92
|
-
4. Import content type and sample content via platform (npx
|
|
89
|
+
1. Verify DC CLI authentication (npx decoupled-cli auth status)
|
|
90
|
+
2. Set default space if needed (npx decoupled-cli spaces use <id>)
|
|
91
|
+
3. Create DC Import JSON for [content_type]
|
|
92
|
+
4. Import content type and sample content via platform (npx decoupled-cli spaces content-import)
|
|
93
93
|
5. **CRITICAL**: Run schema generation (`npm run generate-schema`) to update GraphQL schema
|
|
94
94
|
6. Create TypeScript types and GraphQL queries
|
|
95
95
|
7. Build frontend components ([ContentCard], [ContentRenderer])
|
|
@@ -103,23 +103,23 @@ Use OAuth authentication for direct Drupal content import, then frontend develop
|
|
|
103
103
|
**ALWAYS start by verifying CLI setup:**
|
|
104
104
|
```bash
|
|
105
105
|
# Check if CLI is authenticated
|
|
106
|
-
npx
|
|
106
|
+
npx decoupled-cli auth status
|
|
107
107
|
|
|
108
108
|
# If not authenticated, choose authentication method:
|
|
109
109
|
# For local development with Drupal OAuth:
|
|
110
|
-
npx
|
|
110
|
+
npx decoupled-cli auth oauth
|
|
111
111
|
|
|
112
112
|
# For production with personal access token:
|
|
113
|
-
npx
|
|
113
|
+
npx decoupled-cli auth login
|
|
114
114
|
|
|
115
115
|
# List available spaces and set default
|
|
116
|
-
npx
|
|
117
|
-
npx
|
|
116
|
+
npx decoupled-cli spaces list
|
|
117
|
+
npx decoupled-cli spaces use <space_id>
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
**If CLI authentication fails:**
|
|
121
121
|
- For OAuth: Verify `.env.local` contains `NEXT_PUBLIC_DRUPAL_BASE_URL`, `DRUPAL_CLIENT_ID`, `DRUPAL_CLIENT_SECRET`
|
|
122
|
-
- For personal tokens: Check that
|
|
122
|
+
- For personal tokens: Check that DC platform is accessible
|
|
123
123
|
- Ensure user has proper permissions for the operations you're trying to perform
|
|
124
124
|
|
|
125
125
|
**Important: Command Availability by Authentication Method**
|
|
@@ -127,11 +127,11 @@ npx dcloud-cli spaces use <space_id>
|
|
|
127
127
|
- **PAT-only commands**: `spaces list`, `spaces use`, `usage`, `org info`
|
|
128
128
|
- **Universal commands**: `auth login`, `auth oauth`, `auth test`
|
|
129
129
|
|
|
130
|
-
### 2.
|
|
130
|
+
### 2. DC Import JSON Creation
|
|
131
131
|
|
|
132
132
|
**Get example format with CLI:**
|
|
133
133
|
```bash
|
|
134
|
-
npx
|
|
134
|
+
npx decoupled-cli spaces content-import --example > my-content-type.json
|
|
135
135
|
```
|
|
136
136
|
|
|
137
137
|
**Use this JSON structure:**
|
|
@@ -186,32 +186,32 @@ npx dcloud-cli spaces content-import --example > my-content-type.json
|
|
|
186
186
|
- **For image fields**: Use full URLs with the Drupal domain from `.env.local`, not relative paths:
|
|
187
187
|
```json
|
|
188
188
|
"featured_image": {
|
|
189
|
-
"uri": "${DRUPAL_BASE_URL}/modules/custom/
|
|
189
|
+
"uri": "${DRUPAL_BASE_URL}/modules/custom/dc_import/resources/placeholder.png",
|
|
190
190
|
"alt": "Description of the image",
|
|
191
191
|
"title": "Image title"
|
|
192
192
|
}
|
|
193
193
|
```
|
|
194
194
|
Always read the `NEXT_PUBLIC_DRUPAL_BASE_URL` from `.env.local` and use that as the base for image URIs to ensure images load correctly from the Drupal backend.
|
|
195
195
|
|
|
196
|
-
### 3. Import via
|
|
196
|
+
### 3. Import via DC CLI
|
|
197
197
|
|
|
198
198
|
**Import Content Type:**
|
|
199
199
|
```bash
|
|
200
200
|
# NEW: Import content directly to your Drupal site (OAuth authentication)
|
|
201
|
-
npx
|
|
201
|
+
npx decoupled-cli content import --file content-type-import.json
|
|
202
202
|
|
|
203
203
|
# Or preview first to see what will be imported
|
|
204
|
-
npx
|
|
204
|
+
npx decoupled-cli content import --file content-type-import.json --preview
|
|
205
205
|
|
|
206
|
-
# LEGACY: Import via
|
|
207
|
-
npx
|
|
208
|
-
npx
|
|
206
|
+
# LEGACY: Import via Decoupled Drupal platform (requires PAT authentication and space setup)
|
|
207
|
+
npx decoupled-cli spaces content-import --file content-type-import.json
|
|
208
|
+
npx decoupled-cli spaces content-import <space_id> --file content-type-import.json
|
|
209
209
|
```
|
|
210
210
|
|
|
211
211
|
**Generate example import file:**
|
|
212
212
|
```bash
|
|
213
213
|
# Get example import JSON structure (works with both methods)
|
|
214
|
-
npx
|
|
214
|
+
npx decoupled-cli content import --example > content-type-import.json
|
|
215
215
|
# Then edit the generated file with your content type definition
|
|
216
216
|
```
|
|
217
217
|
|
|
@@ -220,7 +220,7 @@ npx dcloud-cli content import --example > content-type-import.json
|
|
|
220
220
|
- Field machine names (auto-generated)
|
|
221
221
|
- Node IDs created
|
|
222
222
|
- GraphQL schema updates
|
|
223
|
-
- **Important**: GraphQL field names may differ from
|
|
223
|
+
- **Important**: GraphQL field names may differ from DC field IDs (check actual schema)
|
|
224
224
|
|
|
225
225
|
**CRITICAL: Immediately Update GraphQL Schema After Import:**
|
|
226
226
|
```bash
|
|
@@ -500,7 +500,7 @@ npm run dev
|
|
|
500
500
|
### 6. Testing Checklist
|
|
501
501
|
|
|
502
502
|
**Verify each step:**
|
|
503
|
-
- [ ]
|
|
503
|
+
- [ ] DC import successful with no errors
|
|
504
504
|
- [ ] GraphQL schema includes new content type
|
|
505
505
|
- [ ] TypeScript types are properly defined
|
|
506
506
|
- [ ] Build process completes without errors
|
|
@@ -540,7 +540,7 @@ npm run dev
|
|
|
540
540
|
```json
|
|
541
541
|
"product_images": [
|
|
542
542
|
{
|
|
543
|
-
"uri": "${DRUPAL_BASE_URL}/modules/custom/
|
|
543
|
+
"uri": "${DRUPAL_BASE_URL}/modules/custom/dc_import/resources/placeholder.png",
|
|
544
544
|
"alt": "Product showcase image",
|
|
545
545
|
"title": "Product Image"
|
|
546
546
|
}
|
|
@@ -588,7 +588,7 @@ npm run dev
|
|
|
588
588
|
**Sample content with image URI:**
|
|
589
589
|
```json
|
|
590
590
|
"profile_image": {
|
|
591
|
-
"uri": "${DRUPAL_BASE_URL}/modules/custom/
|
|
591
|
+
"uri": "${DRUPAL_BASE_URL}/modules/custom/dc_import/resources/placeholder.png",
|
|
592
592
|
"alt": "Team member headshot",
|
|
593
593
|
"title": "Profile Photo"
|
|
594
594
|
}
|
|
@@ -617,7 +617,7 @@ npm run dev
|
|
|
617
617
|
```json
|
|
618
618
|
"project_images": [
|
|
619
619
|
{
|
|
620
|
-
"uri": "${DRUPAL_BASE_URL}/modules/custom/
|
|
620
|
+
"uri": "${DRUPAL_BASE_URL}/modules/custom/dc_import/resources/placeholder.png",
|
|
621
621
|
"alt": "Project screenshot showing main interface",
|
|
622
622
|
"title": "Project Interface"
|
|
623
623
|
}
|
|
@@ -628,7 +628,7 @@ npm run dev
|
|
|
628
628
|
|
|
629
629
|
### Common Issues
|
|
630
630
|
|
|
631
|
-
**1.
|
|
631
|
+
**1. DC Import Fails**
|
|
632
632
|
- Check OAuth token expiration
|
|
633
633
|
- Verify JSON structure matches `schema/sample.json` format
|
|
634
634
|
- Ensure field IDs don't start with `field_`
|
|
@@ -645,15 +645,15 @@ npm run dev
|
|
|
645
645
|
- Verify GraphQL query syntax
|
|
646
646
|
|
|
647
647
|
**4. Content Not Displaying**
|
|
648
|
-
- Check GraphQL query field names match Drupal fields (may not match
|
|
648
|
+
- Check GraphQL query field names match Drupal fields (may not match DC field IDs)
|
|
649
649
|
- Verify content was created and published
|
|
650
650
|
- Check query variables and pagination
|
|
651
651
|
- For HTML content showing raw tags, use `dangerouslySetInnerHTML={{ __html: field.processed }}`
|
|
652
652
|
|
|
653
|
-
**5. GraphQL Schema Not Updated After
|
|
654
|
-
- **Critical Issue**:
|
|
653
|
+
**5. GraphQL Schema Not Updated After DC Import**
|
|
654
|
+
- **Critical Issue**: DC imports create content types successfully but GraphQL schema may not update immediately
|
|
655
655
|
- Content exists in Drupal but `nodeProducts` query returns "field not found" errors
|
|
656
|
-
- This is the most common issue with
|
|
656
|
+
- This is the most common issue with DC imports
|
|
657
657
|
|
|
658
658
|
**Solution Process**:
|
|
659
659
|
1. Clear Drupal caches (if you have admin access)
|
|
@@ -663,7 +663,7 @@ npm run dev
|
|
|
663
663
|
|
|
664
664
|
### Essential Schema Generation Workflow
|
|
665
665
|
|
|
666
|
-
**CRITICAL**: Always run schema generation after
|
|
666
|
+
**CRITICAL**: Always run schema generation after DC imports to ensure GraphQL integration works properly.
|
|
667
667
|
|
|
668
668
|
```bash
|
|
669
669
|
# Generate updated GraphQL schema after content type imports
|
|
@@ -677,7 +677,7 @@ This command:
|
|
|
677
677
|
- Validates that new content types are available in GraphQL
|
|
678
678
|
|
|
679
679
|
**Add this to your workflow**:
|
|
680
|
-
1. Import content type via
|
|
680
|
+
1. Import content type via DC API
|
|
681
681
|
2. **Immediately run**: `npm run generate-schema`
|
|
682
682
|
3. Check generated schema includes your new content type
|
|
683
683
|
4. Test GraphQL queries
|
|
@@ -687,17 +687,17 @@ This command:
|
|
|
687
687
|
|
|
688
688
|
```bash
|
|
689
689
|
# Check CLI authentication status
|
|
690
|
-
npx
|
|
690
|
+
npx decoupled-cli auth status
|
|
691
691
|
|
|
692
692
|
# OAUTH/DRUPAL COMMANDS:
|
|
693
693
|
# Check content import API status
|
|
694
|
-
npx
|
|
694
|
+
npx decoupled-cli content status
|
|
695
695
|
|
|
696
696
|
# Preview content import without applying changes
|
|
697
|
-
npx
|
|
697
|
+
npx decoupled-cli content import --file your-import.json --preview
|
|
698
698
|
|
|
699
699
|
# Import content to Drupal
|
|
700
|
-
npx
|
|
700
|
+
npx decoupled-cli content import --file your-import.json
|
|
701
701
|
|
|
702
702
|
# Generate fresh schema (most important after any import)
|
|
703
703
|
npm run generate-schema
|
|
@@ -706,22 +706,22 @@ npm run generate-schema
|
|
|
706
706
|
npm run generate-schema
|
|
707
707
|
grep -i [your_content_type] schema/schema.graphql
|
|
708
708
|
|
|
709
|
-
# PAT/PLATFORM COMMANDS (require npx
|
|
709
|
+
# PAT/PLATFORM COMMANDS (require npx decoupled-cli auth login):
|
|
710
710
|
# List available spaces
|
|
711
|
-
npx
|
|
711
|
+
npx decoupled-cli spaces list
|
|
712
712
|
|
|
713
713
|
# Check current default space
|
|
714
|
-
npx
|
|
714
|
+
npx decoupled-cli spaces current
|
|
715
715
|
|
|
716
|
-
# Get health status of
|
|
717
|
-
npx
|
|
716
|
+
# Get health status of DC platform
|
|
717
|
+
npx decoupled-cli health check
|
|
718
718
|
|
|
719
719
|
# Check organization info
|
|
720
|
-
npx
|
|
720
|
+
npx decoupled-cli org info
|
|
721
721
|
|
|
722
722
|
# Legacy platform content import
|
|
723
|
-
npx
|
|
724
|
-
npx
|
|
723
|
+
npx decoupled-cli spaces content-import --file your-import.json --preview
|
|
724
|
+
npx decoupled-cli spaces content-import --file your-import.json --json
|
|
725
725
|
```
|
|
726
726
|
|
|
727
727
|
## Content Import Command Reference
|
|
@@ -730,22 +730,22 @@ npx dcloud-cli spaces content-import --file your-import.json --json
|
|
|
730
730
|
|
|
731
731
|
**Check content import API status:**
|
|
732
732
|
```bash
|
|
733
|
-
npx
|
|
733
|
+
npx decoupled-cli content status
|
|
734
734
|
```
|
|
735
735
|
|
|
736
736
|
**Generate example import JSON:**
|
|
737
737
|
```bash
|
|
738
|
-
npx
|
|
738
|
+
npx decoupled-cli content import --example > my-content-type.json
|
|
739
739
|
```
|
|
740
740
|
|
|
741
741
|
**Preview import (dry run):**
|
|
742
742
|
```bash
|
|
743
|
-
npx
|
|
743
|
+
npx decoupled-cli content import --file my-content-type.json --preview
|
|
744
744
|
```
|
|
745
745
|
|
|
746
746
|
**Import content to Drupal:**
|
|
747
747
|
```bash
|
|
748
|
-
npx
|
|
748
|
+
npx decoupled-cli content import --file my-content-type.json
|
|
749
749
|
```
|
|
750
750
|
|
|
751
751
|
### Authentication Setup for Content Import
|
|
@@ -754,13 +754,13 @@ npx dcloud-cli content import --file my-content-type.json
|
|
|
754
754
|
```bash
|
|
755
755
|
# 1. Ensure .env.local has OAuth credentials
|
|
756
756
|
# 2. Set up OAuth profile
|
|
757
|
-
npx
|
|
757
|
+
npx decoupled-cli auth oauth
|
|
758
758
|
|
|
759
759
|
# 3. Verify it's working
|
|
760
|
-
npx
|
|
760
|
+
npx decoupled-cli content status
|
|
761
761
|
|
|
762
762
|
# 4. Import content
|
|
763
|
-
npx
|
|
763
|
+
npx decoupled-cli content import --file your-content.json
|
|
764
764
|
```
|
|
765
765
|
|
|
766
766
|
**When to use OAuth vs PAT:**
|
|
@@ -778,7 +778,7 @@ npx dcloud-cli content import --file your-content.json
|
|
|
778
778
|
7. **Include proper TypeScript types** for all data structures
|
|
779
779
|
8. **Test the full user journey** from listing to detail pages
|
|
780
780
|
9. **Use `dangerouslySetInnerHTML`** for processed HTML content from Drupal to avoid raw tag display
|
|
781
|
-
10. **Verify GraphQL field names** match actual schema, not
|
|
781
|
+
10. **Verify GraphQL field names** match actual schema, not DC field IDs
|
|
782
782
|
|
|
783
783
|
## Success Criteria
|
|
784
784
|
|
|
@@ -796,7 +796,7 @@ A successful end-to-end implementation should:
|
|
|
796
796
|
|
|
797
797
|
Based on successful product catalog implementation, here are critical learnings to avoid common pitfalls:
|
|
798
798
|
|
|
799
|
-
###
|
|
799
|
+
### DC Import Format Issues
|
|
800
800
|
|
|
801
801
|
**Problem**: Field values incorrectly formatted with "field_" prefix
|
|
802
802
|
```json
|
|
@@ -817,14 +817,14 @@ Based on successful product catalog implementation, here are critical learnings
|
|
|
817
817
|
|
|
818
818
|
### GraphQL Field Name Mapping
|
|
819
819
|
|
|
820
|
-
**Problem**: Assuming GraphQL field names match
|
|
820
|
+
**Problem**: Assuming GraphQL field names match DC field IDs
|
|
821
821
|
```typescript
|
|
822
822
|
// WRONG - Field names may be transformed
|
|
823
|
-
price: string //
|
|
823
|
+
price: string // DC field ID
|
|
824
824
|
fieldPrice: string // What you might expect in GraphQL
|
|
825
825
|
|
|
826
826
|
// CORRECT - Check actual schema
|
|
827
|
-
price: string // Actual GraphQL field name (can match
|
|
827
|
+
price: string // Actual GraphQL field name (can match DC ID)
|
|
828
828
|
inStock: boolean // camelCase transformation
|
|
829
829
|
productImages: object // snake_case to camelCase
|
|
830
830
|
```
|
|
@@ -833,7 +833,7 @@ productImages: object // snake_case to camelCase
|
|
|
833
833
|
|
|
834
834
|
### GraphQL Field Value Structure Discovery
|
|
835
835
|
|
|
836
|
-
**Critical Learning**: GraphQL field values from
|
|
836
|
+
**Critical Learning**: GraphQL field values from DC imports return as simple types, not objects:
|
|
837
837
|
|
|
838
838
|
```typescript
|
|
839
839
|
// WRONG - Assuming field values are objects with .processed
|
|
@@ -844,7 +844,7 @@ fieldFeatures?: Array<{
|
|
|
844
844
|
processed: string
|
|
845
845
|
}>
|
|
846
846
|
|
|
847
|
-
// CORRECT -
|
|
847
|
+
// CORRECT - DC imports create simple value fields
|
|
848
848
|
price?: string
|
|
849
849
|
features?: string[]
|
|
850
850
|
```
|
|
@@ -957,29 +957,29 @@ npm run dev # Test in development mode
|
|
|
957
957
|
|
|
958
958
|
The most important learning from the product catalog implementation is the **mandatory schema generation step**:
|
|
959
959
|
|
|
960
|
-
**Problem**:
|
|
960
|
+
**Problem**: DC imports successfully create content types and content, but GraphQL schema doesn't update automatically.
|
|
961
961
|
**Symptoms**:
|
|
962
962
|
- `nodeProducts` query returns "field not found" errors
|
|
963
963
|
- Content exists in Drupal but not accessible via GraphQL
|
|
964
964
|
- Route queries work but content type queries fail
|
|
965
965
|
|
|
966
|
-
**Solution**: **ALWAYS run schema generation immediately after
|
|
966
|
+
**Solution**: **ALWAYS run schema generation immediately after DC imports**:
|
|
967
967
|
|
|
968
968
|
```bash
|
|
969
|
-
# After any
|
|
969
|
+
# After any DC import, immediately run:
|
|
970
970
|
npm run generate-schema
|
|
971
971
|
|
|
972
972
|
# This step is MANDATORY for GraphQL integration to work
|
|
973
973
|
```
|
|
974
974
|
|
|
975
975
|
**Why this is critical**:
|
|
976
|
-
-
|
|
976
|
+
- DC API creates Drupal content types but doesn't trigger GraphQL schema rebuilds
|
|
977
977
|
- The `generate-schema` script performs fresh introspection and updates local schema files
|
|
978
978
|
- Without this step, frontend development will fail with "type not found" errors
|
|
979
979
|
- This step bridges the gap between Drupal content type creation and Next.js GraphQL integration
|
|
980
980
|
|
|
981
981
|
**Workflow Integration**:
|
|
982
|
-
1. Import via
|
|
982
|
+
1. Import via DC API ✅
|
|
983
983
|
2. **Run `npm run generate-schema`** ✅ ← CRITICAL STEP
|
|
984
984
|
3. Verify schema includes new content type ✅
|
|
985
985
|
4. Proceed with frontend development ✅
|
|
@@ -989,7 +989,7 @@ This learning transforms the development workflow from "sometimes works" to "rel
|
|
|
989
989
|
### Additional Key Learnings
|
|
990
990
|
|
|
991
991
|
#### GraphQL Field Name Discovery (CRITICAL)
|
|
992
|
-
**Always verify actual GraphQL field names after
|
|
992
|
+
**Always verify actual GraphQL field names after DC import** - they may differ from field IDs used in import JSON.
|
|
993
993
|
|
|
994
994
|
**Field Name Transformations**:
|
|
995
995
|
- `in_stock` becomes `inStock` (camelCase)
|
|
@@ -1039,7 +1039,7 @@ const getActiveTab = () => {
|
|
|
1039
1039
|
#### Build Process Integration
|
|
1040
1040
|
**Essential Commands Sequence**:
|
|
1041
1041
|
```bash
|
|
1042
|
-
# After
|
|
1042
|
+
# After DC import, always run:
|
|
1043
1043
|
npm run generate-schema # Updates GraphQL schema
|
|
1044
1044
|
npm run build # Validates TypeScript and builds
|
|
1045
1045
|
npm run dev # Test in development
|