From 9c37f89731dfa5398146041428111db847dce138 Mon Sep 17 00:00:00 2001 From: angrykoala Date: Thu, 21 Mar 2024 13:56:55 +0000 Subject: [PATCH 1/4] Add an example for using input arguments with cypher --- .../type-definitions/directives/cypher.adoc | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/ROOT/pages/type-definitions/directives/cypher.adoc b/modules/ROOT/pages/type-definitions/directives/cypher.adoc index 3001d36e..c26571b5 100644 --- a/modules/ROOT/pages/type-definitions/directives/cypher.adoc +++ b/modules/ROOT/pages/type-definitions/directives/cypher.adoc @@ -154,6 +154,26 @@ type Query { The downside of the latter approach is that you need to adjust the return object as you change your object type definition. +== Input arguments +The `@cypher` statement can access the query parameters by prepending `$` to the parameter name. For example: + +[source, graphql, indent=0] +---- +type Query { + name(value: String): String @cypher(statement: "RETURN $value AS res", columnName: "res") +} +---- + +The following GraphQL query will return the parameter `value`: + +[source, graphql, indent=0] +---- +query { + name(value: "aca") +} +---- + + == Usage examples The `@cypher` directive can be used in different contexts, such as the ones described in this section. @@ -234,4 +254,4 @@ type Mutation { columnName: "a" ) } ----- \ No newline at end of file +---- From 4c6ea19564067fbbfa1d083a7071b5d9d3f1f0fc Mon Sep 17 00:00:00 2001 From: angrykoala Date: Tue, 26 Mar 2024 11:02:31 +0100 Subject: [PATCH 2/4] Update modules/ROOT/pages/type-definitions/directives/cypher.adoc Co-authored-by: Richard Sill <156673635+rsill-neo4j@users.noreply.github.com> --- modules/ROOT/pages/type-definitions/directives/cypher.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/type-definitions/directives/cypher.adoc b/modules/ROOT/pages/type-definitions/directives/cypher.adoc index c26571b5..ebddf44f 100644 --- a/modules/ROOT/pages/type-definitions/directives/cypher.adoc +++ b/modules/ROOT/pages/type-definitions/directives/cypher.adoc @@ -164,7 +164,7 @@ type Query { } ---- -The following GraphQL query will return the parameter `value`: +The following GraphQL query returns the parameter `value`: [source, graphql, indent=0] ---- From c64329246a3523b9d63e2068f844a6d704722c9a Mon Sep 17 00:00:00 2001 From: angrykoala Date: Tue, 26 Mar 2024 10:04:01 +0000 Subject: [PATCH 3/4] Improve example query for cypher directive --- modules/ROOT/pages/type-definitions/directives/cypher.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/type-definitions/directives/cypher.adoc b/modules/ROOT/pages/type-definitions/directives/cypher.adoc index ebddf44f..2257e28f 100644 --- a/modules/ROOT/pages/type-definitions/directives/cypher.adoc +++ b/modules/ROOT/pages/type-definitions/directives/cypher.adoc @@ -169,7 +169,7 @@ The following GraphQL query returns the parameter `value`: [source, graphql, indent=0] ---- query { - name(value: "aca") + name(value: "Arthur") } ---- From b073c4be8f820533a856ded988067c5b0d0199bc Mon Sep 17 00:00:00 2001 From: angrykoala Date: Mon, 8 Apr 2024 11:10:58 +0200 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Richard Sill <156673635+rsill-neo4j@users.noreply.github.com> --- modules/ROOT/pages/type-definitions/directives/cypher.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/type-definitions/directives/cypher.adoc b/modules/ROOT/pages/type-definitions/directives/cypher.adoc index 2257e28f..0510a21b 100644 --- a/modules/ROOT/pages/type-definitions/directives/cypher.adoc +++ b/modules/ROOT/pages/type-definitions/directives/cypher.adoc @@ -169,7 +169,7 @@ The following GraphQL query returns the parameter `value`: [source, graphql, indent=0] ---- query { - name(value: "Arthur") + name(value: "Jane Smith") } ----