From 95294726df89a32d36a43689f5ff2a88710944f1 Mon Sep 17 00:00:00 2001 From: angrykoala Date: Tue, 9 Dec 2025 13:55:37 +0000 Subject: [PATCH 1/2] Docs on populatedByOperation --- .../ROOT/pages/directives/custom-logic.adoc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/ROOT/pages/directives/custom-logic.adoc b/modules/ROOT/pages/directives/custom-logic.adoc index 45370ddc..61c18507 100644 --- a/modules/ROOT/pages/directives/custom-logic.adoc +++ b/modules/ROOT/pages/directives/custom-logic.adoc @@ -597,4 +597,21 @@ new Neo4jGraphQL({ }) ---- -Note that the second positional argument, in this case `_args`, has a type of `Record`, and as such it will always be an empty object. +Note that the second positional argument, in this case `_args`, has a type of `Record`, and as such it will always be an empty object, this is to maintain a compatible signature with GraphQL resolvers. + + +**`populatedByOperation`** + +The `context` argument contains the field `populatedByOperation`. This field is the mutation type that triggered the callback (`CREATE` or `UPDATE`). `populatedByOperation` allows for different logic to be executed depending on the type of operation. For example: + +[source, javascript, indent=0] +---- +const modifiedByCallback = async (_parent, _args, context) => { + if(context.populatedByOperation === "UPDATE"){ + return context.username; + } else { + return ""; + } +} +---- + From 3ffa99911374f66d5d6492e282e9dff9c3874384 Mon Sep 17 00:00:00 2001 From: angrykoala Date: Mon, 15 Dec 2025 09:48:52 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Richard Sill <156673635+rsill-neo4j@users.noreply.github.com> --- modules/ROOT/pages/directives/custom-logic.adoc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/ROOT/pages/directives/custom-logic.adoc b/modules/ROOT/pages/directives/custom-logic.adoc index 61c18507..cb5682a4 100644 --- a/modules/ROOT/pages/directives/custom-logic.adoc +++ b/modules/ROOT/pages/directives/custom-logic.adoc @@ -597,12 +597,16 @@ new Neo4jGraphQL({ }) ---- -Note that the second positional argument, in this case `_args`, has a type of `Record`, and as such it will always be an empty object, this is to maintain a compatible signature with GraphQL resolvers. +Note that the second positional argument, in this case `_args`, has a type of `Record`, and as such it is always an empty object. +This is to maintain a compatible signature with GraphQL resolvers. **`populatedByOperation`** -The `context` argument contains the field `populatedByOperation`. This field is the mutation type that triggered the callback (`CREATE` or `UPDATE`). `populatedByOperation` allows for different logic to be executed depending on the type of operation. For example: +The `context` argument contains the field `populatedByOperation`. +This field is the mutation type that triggered the callback (`CREATE` or `UPDATE`). +`populatedByOperation` allows for different logic to be executed depending on the type of operation. +For example: [source, javascript, indent=0] ----