0
0
GraphQLquery~10 mins

Subgraph definition 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 subgraph with a name.

GraphQL
subgraph [1] {
  // schema details here
}
Drag options to blanks, or click blank then click option'
Aschema
Bquery
Ctype
DMySubgraph
Attempts:
3 left
💡 Hint
Common Mistakes
Using reserved keywords like 'schema' or 'type' as the subgraph name.
Leaving the subgraph name blank.
2fill in blank
medium

Complete the code to specify the GraphQL schema inside the subgraph.

GraphQL
subgraph MySubgraph {
  [1] {
    query: Query
  }
}
Drag options to blanks, or click blank then click option'
Aschema
Btype
Cinterface
Dfragment
Attempts:
3 left
💡 Hint
Common Mistakes
Using type instead of schema for the schema block.
Omitting the schema block.
3fill in blank
hard

Fix the error in the subgraph definition by completing the type declaration.

GraphQL
type Query [1]
  product(id: ID!): Product
}
Drag options to blanks, or click blank then click option'
Aimplements Node
B{
Cextends
Dinterface
Attempts:
3 left
💡 Hint
Common Mistakes
Using implements Node without defining the interface.
Missing the opening curly brace.
4fill in blank
hard

Complete the code to define a Product type with an ID and a name field.

GraphQL
type Product { 
  id: [1]!
  name: String
}
Drag options to blanks, or click blank then click option'
A{
BID
CInt
DString
Attempts:
3 left
💡 Hint
Common Mistakes
Using Int or String for the id field instead of ID.
Omitting the opening curly brace.
5fill in blank
hard

Fill both blanks to define a subgraph with a schema and a Product type with id and name.

GraphQL
subgraph [1] {
  [2] {
    query: Query
  }

  type Product { 
    id: ID!
    name: String
  }
}
Drag options to blanks, or click blank then click option'
AMySubgraph
Bschema
C{
Dtype
Attempts:
3 left
💡 Hint
Common Mistakes
Using type instead of schema for the schema block.
Missing curly braces for the type fields.