0
0
GraphQLquery~10 mins

Interface types 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 declare an interface named Character.

GraphQL
interface [1] { id: ID! name: String! }
Drag options to blanks, or click blank then click option'
ACharacter
BObject
CType
DSchema
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Type' or 'Object' instead of the interface name.
Forgetting to name the interface.
2fill in blank
medium

Complete the code to make the type Human implement the Character interface.

GraphQL
type Human implements [1] { id: ID! name: String! homePlanet: String }
Drag options to blanks, or click blank then click option'
ACharacter
BBeing
CPerson
DEntity
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different name than the interface declared.
Omitting the 'implements' keyword.
3fill in blank
hard

Fix the error in the query to fetch the name from a Character interface type.

GraphQL
query { character(id: "1000") { [1] } }
Drag options to blanks, or click blank then click option'
Aspecies
BhomePlanet
Cheight
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Querying fields not declared in the interface causes errors.
Confusing interface fields with type-specific fields.
4fill in blank
hard

Fill both blanks to query the name and homePlanet of a Human type implementing Character.

GraphQL
query { human(id: "1000") { [1] [2] } }
Drag options to blanks, or click blank then click option'
Aname
BhomePlanet
Cid
Dspecies
Attempts:
3 left
💡 Hint
Common Mistakes
Querying fields not defined in Human or Character.
Mixing up field names.
5fill in blank
hard

Fill all three blanks to define an interface and two types implementing it with a shared field.

GraphQL
interface [1] { id: ID! name: String! } type [2] implements [1] { id: ID! name: String! age: Int } type Droid implements [1] { id: ID! name: String! primaryFunction: String }
Drag options to blanks, or click blank then click option'
ACharacter
BHuman
DRobot
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for the interface in the implements clause.
Forgetting to declare the interface name in the type.