Skip to content

Commit 9529472

Browse files
committed
Docs on populatedByOperation
1 parent 1a1f472 commit 9529472

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

modules/ROOT/pages/directives/custom-logic.adoc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,4 +597,21 @@ new Neo4jGraphQL({
597597
})
598598
----
599599

600-
Note that the second positional argument, in this case `_args`, has a type of `Record<string, never>`, and as such it will always be an empty object.
600+
Note that the second positional argument, in this case `_args`, has a type of `Record<string, never>`, and as such it will always be an empty object, this is to maintain a compatible signature with GraphQL resolvers.
601+
602+
603+
**`populatedByOperation`**
604+
605+
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:
606+
607+
[source, javascript, indent=0]
608+
----
609+
const modifiedByCallback = async (_parent, _args, context) => {
610+
if(context.populatedByOperation === "UPDATE"){
611+
return context.username;
612+
} else {
613+
return "";
614+
}
615+
}
616+
----
617+

0 commit comments

Comments
 (0)