@jackchuka/gql-ingest 4.0.0 → 4.2.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 CHANGED
@@ -576,6 +576,54 @@ For transforming flat JSON into nested structures:
576
576
  }
577
577
  ```
578
578
 
579
+ #### Cross-Entity References
580
+
581
+ When one entity needs values produced by another (e.g., a server-generated ID), use `outputCapture` and `$ref`:
582
+
583
+ **users/entity.json** (captures the created ID):
584
+
585
+ ```json
586
+ {
587
+ "name": "users",
588
+ "dataFile": "users.csv",
589
+ "graphqlFile": "users.graphql",
590
+ "mapping": { "name": "user_name", "email": "user_email" },
591
+ "outputCapture": {
592
+ "key": "$.user_name",
593
+ "fields": { "id": "$.createUser.id" }
594
+ }
595
+ }
596
+ ```
597
+
598
+ - `outputCapture.key` — JSONPath into the input row, used as the lookup key
599
+ - `outputCapture.fields` — map of field names to JSONPaths into the mutation response
600
+
601
+ **items/entity.json** (references the captured user ID):
602
+
603
+ ```json
604
+ {
605
+ "name": "items",
606
+ "dataFile": "items.csv",
607
+ "graphqlFile": "items.graphql",
608
+ "mapping": {
609
+ "name": "item_name",
610
+ "sku": "item_sku",
611
+ "createdBy": { "$ref": "users", "key": "$.owner_name", "field": "id" }
612
+ }
613
+ }
614
+ ```
615
+
616
+ - `$ref` — the entity name that captured the value
617
+ - `key` — JSONPath into the current row to get the lookup key
618
+ - `field` — the captured field name to retrieve
619
+
620
+ The referenced entity must be processed first. Entity files are processed in the order they are passed, but you can use `entityDependencies` in `config.yaml` to make the ordering explicit:
621
+
622
+ ```yaml
623
+ entityDependencies:
624
+ items: ["users"]
625
+ ```
626
+
579
627
  ### YAML Format
580
628
 
581
629
  YAML provides a more readable alternative: