Complete the code to define a federated service with a key directive.
type Product @key(fields: "[1]") { id: ID! name: String }
The @key directive specifies the primary field used to identify the entity across services. Here, id is the correct key.
Complete the code to extend a type from another service in federation.
extend type User @key(fields: "[1]") { id: ID! username: String }
When extending a type, the @key directive must use the field that uniquely identifies the entity, typically id.
Fix the error in the federation SDL by completing the missing directive.
type Review { id: ID! body: String author: User [1] }The @external directive marks fields that are owned by another service but referenced here, which is necessary for federation to work correctly.
Fill both blanks to complete the resolver that fetches a federated entity by its key.
User: { __resolveReference([1]) { return fetchUserById([1].[2]); } }The resolver receives the reference object as user, and the key field to fetch the user is id.
Fill all three blanks to complete the federated schema with multiple services.
schema { query: [1] } type [2] { products: [Product] } type Product @key(fields: "[3]") { id: ID! name: String }The schema's query root is Query. The type containing the products field is also Query. The key field for Product is id.