Skip to content

Commit 8e25ca9

Browse files
committed
Fix #6585
1 parent 5f5076d commit 8e25ca9

File tree

7 files changed

+510
-35
lines changed

7 files changed

+510
-35
lines changed

.changeset/yellow-kiwis-go.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@neo4j/graphql": patch
3+
---
4+
5+
Fix regression on `@populatedBy` where nested create operations don't trigger callbacks

packages/graphql/src/translate/queryAST/ast/input-fields/TimestampField.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@ export class TimestampField extends InputField {
3030
super(name, attachedTo);
3131
this.attribute = attribute;
3232
}
33+
3334
public getChildren() {
3435
return [];
3536
}
3637

37-
public print(): string {
38-
return `${super.print()} <${this.name}>`;
39-
}
40-
4138
public getSetParams(queryASTContext: QueryASTContext<Cypher.Node>): Cypher.SetParam[] {
4239
const target = this.getTarget(queryASTContext);
4340
const relatedCypherExpression = this.GetFunctionForTemporalType(

packages/graphql/src/translate/queryAST/factory/Operations/CreateFactory.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -470,31 +470,31 @@ export class CreateFactory {
470470
isNested: boolean;
471471
relationship?: RelationshipAdapter;
472472
}) {
473-
if (!isNested) {
474-
entity.getPopulatedByFields("CREATE").forEach((attribute) => {
475-
const attachedTo = "node";
476-
// the param value it's irrelevant as it will be overwritten by the callback function
477-
const callbackParam = new Cypher.Param("1234");
478-
const field = new ParamInputField({
479-
attribute,
480-
attachedTo,
481-
inputValue: callbackParam,
482-
});
483-
create.addField(field);
473+
entity.getPopulatedByFields("CREATE").forEach((attribute) => {
474+
const attachedTo = "node";
475+
// the param value it's irrelevant as it will be overwritten by the callback function
476+
const callbackParam = new Cypher.Param("1234");
477+
const field = new ParamInputField({
478+
attribute,
479+
attachedTo,
480+
inputValue: callbackParam,
481+
});
482+
create.addField(field);
484483

485-
const callbackFunctionName = attribute.annotations.populatedBy?.callback;
486-
if (!callbackFunctionName) {
487-
throw new Error(`PopulatedBy callback not found for attribute ${attribute.name}`);
488-
}
484+
const callbackFunctionName = attribute.annotations.populatedBy?.callback;
485+
if (!callbackFunctionName) {
486+
throw new Error(`PopulatedBy callback not found for attribute ${attribute.name}`);
487+
}
489488

490-
callbackBucket.addCallback({
491-
functionName: callbackFunctionName,
492-
param: callbackParam,
493-
parent: input,
494-
type: attribute.type,
495-
});
489+
callbackBucket.addCallback({
490+
functionName: callbackFunctionName,
491+
param: callbackParam,
492+
parent: input,
493+
type: attribute.type,
496494
});
497-
} else {
495+
});
496+
497+
if (isNested) {
498498
relationship?.getPopulatedByFields("CREATE").forEach((attribute) => {
499499
const attachedTo = "relationship";
500500
// the param value it's irrelevant as it will be overwritten by the callback function

0 commit comments

Comments
 (0)