Skip to content

Comments

[WIP] 1 1 relationship for v7#7025

Draft
angrykoala wants to merge 18 commits intodevfrom
1-1-relationship
Draft

[WIP] 1 1 relationship for v7#7025
angrykoala wants to merge 18 commits intodevfrom
1-1-relationship

Conversation

@angrykoala
Copy link
Member

@angrykoala angrykoala commented Jan 28, 2026

Description

Adds back limited support for single-relationship (i.e. 1-* and 1-1) to version 7.

This allow for using @relationship directive in non-list fields:

type Movie @node {
    title: String!
    actor: [Actor!]! @relationship(type: "ACTED_IN", direction: IN, properties: "ActedIn")
    director: Director! @relationship(type: "DIRECTED", direction: IN, properties: "Directed")
}

This was removed in v6 due to inherent limitations on maintaining these constraints which could lead to a inconsistent database that could not be queried by GraphQL.

With this PR It will be possible to model and query the data of single element relationships, with the following constraints:

  • If multiple relationships exists, the first one will be returned. The relationship that will be returned will not be guaranteed
  • Connections will maintain the many-to-many API, even if it is a single relationship. This is to maintain the relay spec
  • Delete mutations will be available for nullable fields
  • Create mutations will be available for both, nullable and non-nullable

These rules mean that it is easier to maintain consistency between the GraphQL schema and the underlying data, even if not guaranteed

Future work will be done to add support for more risky operations (mutations on non-nullable fields and update mutations) but data consistency will not be guaranteed at the GraphQL level for these

@angrykoala angrykoala requested a review from a-alle January 28, 2026 10:39
@changeset-bot
Copy link

changeset-bot bot commented Jan 28, 2026

⚠️ No Changeset found

Latest commit: 7ed3c35

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@angrykoala angrykoala changed the title [WIP] 1 1 relationship [WIP] 1 1 relationship for v7 Jan 28, 2026
@neo4j-team-graphql
Copy link
Collaborator

neo4j-team-graphql commented Jan 28, 2026

Performance Report

No Performance Changes

Show Full Table
name dbHits old dbHits time (ms) old time (ms) maxRows
aggregations.TopLevelAggregateWithMultipleFields 7936 7936 50 68 1134
aggregations.NestedAggregation 15407 15407 54 95 2174
aggregations.AggregationWithWhere 10833 10833 38 63 2174
aggregations.AggregationWhereWithinNestedRelationships 20097917 20097917 1963 2094 2008534
aggregations.AggregationWhereWithinNestedConnections 20097917 20097917 1933 1984 2008534
aggregations.InterfacesAggregations 8324 8324 76 111 2080
aggregations.InterfacesAggregationsWithTwoFields 13526 13526 100 125 2080
connections.Connection 12951 12951 53 61 2174
connections.NestedConnection 37705 37705 106 142 4516
connections.totalCount 1 1 33 25 1
cypher-directive-mutation.TopLevelMutationDirective 1135 1135 35 40 1134
cypher-directive.TopLevelSortWithCypher 12961 12961 38 49 2174
cypher-directive.TopLevelConnectionSortWithCypher 12961 12961 55 61 2174
cypher-directive.TopLevelSortWithCypherWithNested 13096 13096 52 100 2174
cypher-directive.TopLevelConnectionSortWithCypherWithNested 13096 13096 72 157 2174
cypher-directive.TopLevelSortWithExpensiveCypher 13725 13725 101 115 2174
cypher-directive.TopLevelConnectionSortWithExpensiveCypher 13266 13266 79 102 2174
fulltext.Fulltext 80 80 36 49 16
fulltext.FulltextWithNestedQuery 516 516 57 72 84
fulltext.FulltextWithSort 259 259 35 43 37
1262.NestedConnectionWhere 8703 8703 49 61 2174
187.QueryWhere 8564 8564 30 41 2154
2871.NestedRelationshipFilter 19632 19632 60 62 4395
batch-create.BatchCreate 3600 3600 85 99 600
connect.createAndConnect 4410 4410 50 58 1134
create.SimpleMutation 6 6 28 31 1
delete.SimpleDelete 19401 19401 654 666 1040
delete.NestedDeleteInUpdate 14688 14688 93 133 1179
update.NestedUpdate 10129 10129 53 73 2002
query.SimpleQuery 3121 3121 22 22 1040
query.SimpleQueryWithRelationship 15031 15031 41 45 2174
query.SimpleQueryWithNestedWhere 8713 8713 53 55 2154
query.Nested 3988 3988 58 67 1040
query.OrFilterOnRelationshipsAndNestedFilters 26947 26759 163 227 2031
query.QueryWithNestedIn 14480 14480 47 74 1960
query.DeeplyNestedConnectionWhere 8702 8702 61 93 2174
query.DeeplyNestedWithRelationshipFilters 17357 17357 109 135 1552
query.NestedWithRelationshipSingleFilters 3808 3808 140 212 1134
sorting.SortMultipleTypes 3436 3436 73 87 1040
sorting.SortMultipleTypesWithCypherWithCypher 13321 13321 76 86 2174
sorting.SortOnNestedFields 12951 12951 40 50 2174
sorting.SortDeeplyNestedFields 39785 39785 92 91 4516
sorting.ConnectionWithSort 3271 3271 54 64 1040
unions.SimpleUnionQuery 321 321 45 49 35
unions.SimpleUnionQueryWithMissingFields 293 293 50 61 35
unions.NestedUnion 309975 309975 238 287 33033

Old Schema Generation: 21.035s
Schema Generation: 21.418s
Old Subgraph Schema Generation: 24.945s
Subgraph Schema Generation: 24.544s

angrykoala and others added 2 commits January 29, 2026 13:27
* implement create: added single type provided check for union, add nullable check for single relationship fields

* add tests for delete

* add tck tests for create, delete

* implement nested delete

* update schema tests with new delete input types

* remove leftover cardinality check

* use testhelper to check nodes and relationships existance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants