You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* A `Person` can _act in_ or _direct_ multiple movies, and a `Movie` can have multiple actors.
55
-
However, it is rare for a `Movie` to have more than one director, so you can model this cardinality in your type definitions, to ensure accuracy of your data.
56
-
* A `Movie` isn't really a `Movie` without a director, and this has been signified by marking the `director` field as non-nullable.
57
-
This means that a `Movie` *must* have a `DIRECTED` relationship coming into it to be valid.
55
+
While it is rare for a `Movie` to have more than one director, Neo4j GraphQL Library requires all relationships to be modeled as "many" relationships (using arrays).
56
+
* Even conceptually one-to-one relationships like a movie having a single director must be represented as arrays (e.g., `directors: [Person!]!`) because Neo4j cannot reliably enforce 1:1 cardinality between nodes.
58
57
* To figure out whether the `direction` argument of the `@relationship` directive should be `IN` or `OUT`, visualize your relationships like in the diagram above, then model out the direction of the arrows.
59
58
* The `@relationship` directive is a reference to Neo4j relationships, whereas in the schema, the phrase `edge(s)` is used to be consistent with the general API language used by Relay.
60
59
60
+
=== Neo4j GraphQL Cardinality Limitation
61
+
62
+
It's important to understand that Neo4j cannot reliably enforce 1:1 cardinality between nodes in a graph database. Therefore, all relationships in Neo4j GraphQL are modeled as "many" relationships (using arrays) even when conceptually they represent one-to-one relationships.
63
+
As alternative you can define your relationship with the `@cypher` directive, however some of the functionality provided by the Neo4j GraphQL Library will not be available.
64
+
61
65
=== Relationship properties
62
66
63
67
You can add relationship properties to the example in two steps:
0 commit comments