From d891ba8b97940763c078ba102a83f805b72e5eea Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Wed, 22 Jul 2026 15:21:42 -0600 Subject: [PATCH 1/2] docs(schema): correct from+to relationship cardinality to many-to-one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The @relationship(from:, to:) example joined two scalar attributes (productSku -> sku) but was labeled "useful for many-to-many relationships" — cardinality in Harper is decided by whether the target `to` attribute is an array (search.ts's isManyToMany check), so a scalar-to-scalar join is many-to-one, not many-to-many. The other bug in issue #582 (querying.md resellers example pointing `from` at the singular resellerId) was already fixed on main by 7e373fa3 before this dispatch ran. Refs #582 Co-Authored-By: Claude Sonnet 5 --- reference/database/schema.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/database/schema.md b/reference/database/schema.md index 7ebaa1ea..6890ec8d 100644 --- a/reference/database/schema.md +++ b/reference/database/schema.md @@ -397,14 +397,14 @@ type Network @table @export { ### `@relationship(from: attribute, to: attribute)` — foreign key to foreign key -Both `from` and `to` can be specified together to define a relationship where neither side uses the primary key — a foreign key to foreign key join. This is useful for many-to-many relationships that join on non-primary-key attributes. +Both `from` and `to` can be specified together to define a relationship where neither side uses the primary key — a foreign key to foreign key join. Cardinality follows the same rule as the `to`-only form above: a scalar `to` attribute gives a many-to-one join (as below); an array `to` attribute gives a many-to-many join, using the array pattern shown in `@relationship(from: attribute)` above. ```graphql type OrderItem @table @export { id: Long @primaryKey orderId: Long @indexed productSku: Long @indexed - product: Product @relationship(from: productSku, to: sku) # join on sku, not primary key + product: Product @relationship(from: productSku, to: sku) # many-to-one join on sku, not primary key } type Product @table @export { From c62e1c46cd3e1a798184a5fd7548abc3b614b174 Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Wed, 22 Jul 2026 16:37:12 -0600 Subject: [PATCH 2/2] Apply suggestion from @gemini-code-assist[bot] Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- reference/database/schema.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/database/schema.md b/reference/database/schema.md index 6890ec8d..891d05f7 100644 --- a/reference/database/schema.md +++ b/reference/database/schema.md @@ -397,7 +397,7 @@ type Network @table @export { ### `@relationship(from: attribute, to: attribute)` — foreign key to foreign key -Both `from` and `to` can be specified together to define a relationship where neither side uses the primary key — a foreign key to foreign key join. Cardinality follows the same rule as the `to`-only form above: a scalar `to` attribute gives a many-to-one join (as below); an array `to` attribute gives a many-to-many join, using the array pattern shown in `@relationship(from: attribute)` above. +Both `from` and `to` can be specified together to define a relationship where neither side uses the primary key — a foreign key to foreign key join. Cardinality is determined by the target (`to`) attribute: a scalar `to` attribute gives a many-to-one join (as below), while an array `to` attribute gives a many-to-many join. ```graphql type OrderItem @table @export {