@memberjunction/graphql-dataprovider 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 +71 -0
- package/dist/index.cjs +49 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +8 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -540,6 +540,77 @@ const syncResult = await systemClient.SyncRolesAndUsers({
|
|
|
540
540
|
});
|
|
541
541
|
```
|
|
542
542
|
|
|
543
|
+
## IS-A Type Relationship Support
|
|
544
|
+
|
|
545
|
+
The GraphQL data provider provides transparent handling of IS-A type relationships (entity inheritance) on the client side. When working with IS-A child entities, the provider seamlessly manages the complexity of parent-child field coordination.
|
|
546
|
+
|
|
547
|
+
### How IS-A Relationships Work
|
|
548
|
+
|
|
549
|
+
For IS-A child entities:
|
|
550
|
+
- **GraphQL Input Types**: Include ALL fields (both parent and child fields) in a single mutation
|
|
551
|
+
- **Client Simplicity**: The client sends one mutation with all fields combined
|
|
552
|
+
- **Server Responsibility**: The GraphQL resolver on the server side handles:
|
|
553
|
+
- Splitting fields between parent and child entities
|
|
554
|
+
- Orchestrating parent saves before child saves
|
|
555
|
+
- Managing transaction boundaries
|
|
556
|
+
- Rolling back changes if any operation fails
|
|
557
|
+
|
|
558
|
+
### Client-Side Behavior
|
|
559
|
+
|
|
560
|
+
```typescript
|
|
561
|
+
// Example: Saving an AIPrompt (child of Template)
|
|
562
|
+
const aiPrompt = await md.GetEntityObject<AIPromptEntity>('AI Prompts');
|
|
563
|
+
aiPrompt.NewRecord();
|
|
564
|
+
|
|
565
|
+
// Set both parent fields (from Template)
|
|
566
|
+
aiPrompt.Name = 'Customer Analysis Prompt';
|
|
567
|
+
aiPrompt.Description = 'Analyzes customer behavior patterns';
|
|
568
|
+
|
|
569
|
+
// Set child fields (from AIPrompt)
|
|
570
|
+
aiPrompt.AIModelID = 'gpt-4-model-id';
|
|
571
|
+
aiPrompt.PromptRole = 'User';
|
|
572
|
+
|
|
573
|
+
// Save - client sends all fields in one mutation
|
|
574
|
+
await aiPrompt.Save();
|
|
575
|
+
// The server handles splitting and saving parent first, then child
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
### Transaction Management
|
|
579
|
+
|
|
580
|
+
Important aspects of transaction handling with IS-A relationships:
|
|
581
|
+
|
|
582
|
+
- **No Client-Side Transactions**: `BaseEntity.ProviderTransaction` remains null on the client side
|
|
583
|
+
- **Server-Side Orchestration**: The GraphQL resolver creates and manages transactions internally
|
|
584
|
+
- **Automatic Rollback**: If either parent or child save fails, all changes are rolled back
|
|
585
|
+
- **Transparent to Client**: The client code doesn't need to manage these complexities
|
|
586
|
+
|
|
587
|
+
### Load Operations
|
|
588
|
+
|
|
589
|
+
When loading IS-A child entities:
|
|
590
|
+
- The GraphQL query returns a merged view with both parent and child fields
|
|
591
|
+
- All fields appear as properties on the entity object
|
|
592
|
+
- No special handling required in client code
|
|
593
|
+
- Field access is seamless regardless of whether it's a parent or child field
|
|
594
|
+
|
|
595
|
+
```typescript
|
|
596
|
+
// Loading returns merged parent + child view
|
|
597
|
+
const prompt = await md.GetEntityObject<AIPromptEntity>('AI Prompts', contextUser);
|
|
598
|
+
await prompt.Load('prompt-id');
|
|
599
|
+
|
|
600
|
+
// Access parent fields
|
|
601
|
+
console.log(prompt.Name); // From Template
|
|
602
|
+
|
|
603
|
+
// Access child fields
|
|
604
|
+
console.log(prompt.PromptRole); // From AIPrompt
|
|
605
|
+
|
|
606
|
+
// Both appear as regular properties with no distinction
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
### Related Documentation
|
|
610
|
+
|
|
611
|
+
For comprehensive information about IS-A relationships in MemberJunction:
|
|
612
|
+
- [IS-A Relationships Architecture](../../MJCore/docs/isa-relationships.md) - Server-side implementation details, entity structure, and transaction management
|
|
613
|
+
|
|
543
614
|
## Key Classes and Types
|
|
544
615
|
|
|
545
616
|
| Class/Type | Description |
|