0
0
GraphQLquery~10 mins

Shared types across subgraphs in GraphQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a shared type in a subgraph schema.

GraphQL
type Product @key(fields: "id") {
  id: ID! 
  name: String! 
  [1]: Float
}
Drag options to blanks, or click blank then click option'
Aprice
Bweight
Cdescription
Dcategory
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a field that is not numeric like 'name' or 'category'.
Leaving the field blank.
2fill in blank
medium

Complete the code to extend a shared type in another subgraph.

GraphQL
extend type Product @key(fields: "id") {
  id: ID! 
  [1]: String
}
Drag options to blanks, or click blank then click option'
Aweight
Bmanufacturer
Cprice
Dstock
Attempts:
3 left
💡 Hint
Common Mistakes
Using fields already defined in the base type like 'price'.
Choosing numeric fields instead of descriptive text.
3fill in blank
hard

Fix the error in the shared type definition by completing the directive.

GraphQL
type User @[1](fields: "id") {
  id: ID! 
  username: String!
}
Drag options to blanks, or click blank then click option'
Akey
Bexternal
Cprovides
Drequires
Attempts:
3 left
💡 Hint
Common Mistakes
Using @external which is for fields, not types.
Using @provides or @requires which are for field-level directives.
4fill in blank
hard

Fill both blanks to correctly mark a field as shared and external.

GraphQL
extend type Review @key(fields: "id") {
  id: ID! 
  username: String @[1] @[2]
}
Drag options to blanks, or click blank then click option'
Aexternal
Bprovides
Drequires
Attempts:
3 left
💡 Hint
Common Mistakes
Using @provides or @requires instead of @external.
Not marking the field as external when extending.
5fill in blank
hard

Fill all three blanks to define a shared type with a key and external field.

GraphQL
type Product @[1](fields: "id") {
  id: ID! 
  name: String!
  price: Float @[2] @[3]
}
Drag options to blanks, or click blank then click option'
Akey
Bexternal
Dprovides
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing @provides with @external.
Not marking the key directive correctly.