Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions reference/database/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. As with the `to`-only form above, the result type must be an array: Harper resolves it by searching the target table's `to` attribute for matches, using this record's `from` attribute (instead of its primary key) as the search value.

```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
products: [Product] @relationship(from: productSku, to: sku) # matches products by sku, not primary key
}

type Product @table @export {
Expand Down