Skip to content

Commit 47927dd

Browse files
Apply suggestions from code review
Co-authored-by: Lidia Zuin <[email protected]>
1 parent 60cdc7c commit 47927dd

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ This directive can be used both for properties in a type or as top level queries
99

1010
=== Global variables
1111

12-
Global variables are available for use within the Cypher statement and can be applied to the `@cypher` directive.
12+
Global variables are available for use within the Cypher statement, and can be applied to the `@cypher` directive.
1313

1414
[cols="1,2,2"]
1515
|===
1616
| Variable | Description | Example
1717

1818
| `this`
19-
| This value is a reference to the currently resolved node, and it can be used to traverse the graph.
19+
| Refers to the currently resolved node, and can be used to traverse the graph.
2020
a|
2121
[source, graphql, indent=0]
2222
----
@@ -99,7 +99,7 @@ type Query {
9999
The return value of Cypher statements must always be of the same type to which the directive is applied.
100100

101101
The variable must also be aliased with a name that is the same as the one passed to `columnName`.
102-
This can be the name of a node, relationship query or an alias in the `RETURN` statement of the Cypher statement.
102+
This can be the name of a node, relationship query, or an alias in the `RETURN` statement of the Cypher statement.
103103

104104
==== Scalar values
105105

@@ -158,7 +158,8 @@ The downside of the latter approach is that you need to adjust the return object
158158

159159
=== Input arguments
160160

161-
The `@cypher` statement can access the query parameters by prepending `$` to the parameter name. For example:
161+
The `@cypher` statement can access the query parameters by prepending `$` to the parameter name.
162+
For example:
162163

163164
[source, graphql, indent=0]
164165
----
@@ -184,7 +185,7 @@ The `@cypher` directive can be used in different contexts, such as the ones desc
184185
[[type-definitions-cypher-object-usage]]
185186
==== On an object type field
186187

187-
In the example below, a field `similarMovies` is bound to the `Movie` type, to find other movies with an overlap of actors:
188+
In the following example, the field `similarMovies` is bound to the `Movie` type for finding other movies with an overlap of actors:
188189

189190
[source, graphql, indent=0]
190191
----
@@ -265,7 +266,8 @@ type Mutation {
265266
When translating from GraphQL to Cypher, any instances of fields to which this directive is applied will be wrapped in a `coalesce()` function in the WHERE clause (see https://neo4j.com/developer/kb/understanding-non-existent-properties-and-null-values/#_use_coalesce_to_use_a_default_for_a_null_value).
266267

267268
This directive helps querying against non-existent properties in a database.
268-
However, it is encouraged to populate these properties with meaningful values if this is becoming the norm. The `@coalesce`directive is a primitive implementation of the function which only takes a static default value as opposed to using another property in a node or a Cypher expression.
269+
However, it is encouraged to populate these properties with meaningful values if it becomes the norm.
270+
The `@coalesce`directive is a primitive implementation of the function which only takes a static default value as opposed to using another property in a node or a Cypher expression.
269271

270272
=== Definition
271273

@@ -337,9 +339,8 @@ If no `default` value is set, `max` is used for queries without limit.
337339

338340
The Neo4j GraphQL Library generates query and mutation resolvers, so you don't need to implement them yourself.
339341
However, if you need additional behaviors besides the autogenerated CRUD operations, you can specify custom resolvers for these scenarios.
340-
This page describes how to set them up.
341342

342-
To add a field to an object type which is resolved from existing values in the type, rather than storing new values, you should mark it with the `@customResolver` directive and define a custom resolver for it.
343+
To add a field to an object type which is resolved from existing values in the type, rather than storing new values, you should mark it with the `@customResolver` directive, and define a custom resolver for it.
343344

344345
Take, for instance, this schema:
345346

@@ -386,11 +387,11 @@ directive @customResolver(
386387

387388
=== The `requires` argument
388389

389-
This is how the `requires` argument can be used on your schema:
390+
The `requires` argument can be used:
390391

391-
* Accepts a selection set string.
392-
* Can be used in any field, as long as it is not another `@customResolver` field.
393-
* Should be used in case the custom resolver depends on any fields.
392+
* For a selection set string.
393+
* In any field, as long as it is not another `@customResolver` field.
394+
* In case the custom resolver depends on any fields.
394395
This ensures that, during the Cypher generation process, these properties are selected from the database.
395396

396397
Using a selection set string makes it possible to select fields from related types, as shown in the following example:
@@ -428,7 +429,7 @@ const neoSchema = new Neo4jGraphQL({
428429
});
429430
----
430431

431-
Here the `firstName`, `lastName`, `address.street`, and `address.city` fields are always selected from the database if the `fullName` field is selected and is available to the custom resolver.
432+
Here the `firstName`, `lastName`, `address.street`, and `address.city` fields are always selected from the database if the `fullName` field is selected, and is available to the custom resolver.
432433

433434
It is also possible to inline fragments to conditionally select fields from interface/union types:
434435

@@ -461,7 +462,7 @@ type Journal implements Publication {
461462
----
462463

463464
However, it is **not** possible to require extra fields generated by the library such as aggregations and connections.
464-
For example, the type definitions below would throw an error as they attempt to require the `publicationsAggregate`:
465+
For example, the following type definitions would throw an error since they attempt to require the `publicationsAggregate`:
465466

466467
[source, graphql, indent=0]
467468
----
@@ -495,7 +496,7 @@ type Journal implements Publication {
495496

496497
== `@populatedBy`
497498

498-
This directive is used to specify a callback function that gets executed during GraphQL query parsing,
499+
This directive is used to specify a callback function, which is executed during GraphQL query parsing,
499500
to populate fields which have not been provided within the input.
500501

501502
For non-required values, callbacks may return `undefined` (meaning that nothing is changed or added to the property) or `null` (meaning that the property will be removed).
@@ -566,7 +567,7 @@ type Record {
566567
}
567568
----
568569

569-
If the username is located in `context.username`, you could define a callback such as:
570+
And if the username is located in `context.username`, you could define a callback such as:
570571

571572
[source, javascript, indent=0]
572573
----

0 commit comments

Comments
 (0)