Introduction
A subgraph defines a part of a larger graph to organize and manage data clearly and efficiently.
Jump into concepts and practice - no test required
type SubgraphName @key(fields: "id") { id: ID! field1: String field2: Int relatedField: RelatedType }
type Product @key(fields: "upc") { upc: String! name: String price: Int }
type User @key(fields: "id") { id: ID! username: String email: String }
type EmptySubgraph {
# No fields defined yet
}type Book @key(fields: "isbn") { isbn: String! title: String author: Author } type Author @key(fields: "id") { id: ID! name: String }
subgraph in a GraphQL architecture?@key directive?type User @key(fields: "userID") {
userID: ID!
name: String
email: String
}{ user { userID name } } in a federated setup?type Product @key(fields: "sku") {
sku: ID!
name: String
price: Float
}type Product @key(fields: "id") {
sku: ID!
name: String
price: Float
}type Product @key(fields: sku) {
sku: ID!
name: String
price: Float
}type Product @key(fields: "sku") {
sku: ID!
name: String
price: Float
}type Product {
sku: ID!
name: String
price: Float
}orderID and a list of items. Which is the best way to define the subgraph schema to support federation and ensure uniqueness?