Relationships
Introduction
Defining a relationship allows you to make queries across linked information.
Relationships are defined in metadata from an object type, to a model or command.
This enables you to create complex queries, where you can fetch related data in a single query.
By defining a Relationship
object, all models or commands whose output type is the
source object type defined in the relationship will now have a connection to the target model or command.
So from this relationship definition, all models or commands in the supergraph whose output type is the orders
object
type will now have a connection to the customers
model via the customer
relationship field on the orders
type.
So, as in example 1 below, you can now fetch the customer when you query orders. Note that also, if you had, for
instance an arbitrary command such as getCustomerLastOrder
which also returned an order from a customer id, you can
now also return the customer's details for that returned order in the same single query from this relationship.