MCPcopy Create free account
hub / github.com/codemix/graph / convertSetClause

Function convertSetClause

packages/graph/src/astToSteps.ts:527–556  ·  view source on GitHub ↗

* Convert a SET clause into a SetStep. * Supports three types of assignments: * 1. Individual property: n.prop = value * 2. Replace all properties: n = {props} * 3. Add/merge properties: n += {props}

(setClause: SetClause)

Source from the content-addressed store, hash-verified

525 * 3. Add/merge properties: n += {props}
526 */
527function convertSetClause(setClause: SetClause): SetStep {
528 const assignments: StepSetOperation[] = setClause.assignments.map((assignment) => {
529 // Check for SetAllProperties or SetAddProperties (map-based assignments)
530 if ("type" in assignment) {
531 if (assignment.type === "SetAllProperties") {
532 const setAll = assignment as SetAllProperties;
533 return {
534 type: "setAllProperties" as const,
535 variable: setAll.variable,
536 properties: convertSetMapValue(setAll.properties),
537 };
538 } else if (assignment.type === "SetAddProperties") {
539 const setAdd = assignment as SetAddProperties;
540 return {
541 type: "setAddProperties" as const,
542 variable: setAdd.variable,
543 properties: convertSetMapValue(setAdd.properties),
544 };
545 }
546 }
547 // Individual property assignment: n.prop = value
548 return {
549 variable: assignment.variable,
550 property: assignment.property,
551 value: convertSetValue(assignment.value),
552 };
553 });
554
555 return new SetStep({ assignments });
556}
557
558/**
559 * Convert a SET map value (property map or parameter reference).

Callers 2

processQuerySegmentsFunction · 0.85
processLegacyQueryFunction · 0.85

Calls 3

convertSetMapValueFunction · 0.85
convertSetValueFunction · 0.85
mapMethod · 0.45

Tested by

no test coverage detected