0
0
GraphQLquery~10 mins

Abstract type resolution 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 an interface named Character.

GraphQL
interface Character [1] {
  id: ID!
  name: String!
}
Drag options to blanks, or click blank then click option'
Aimplements
Bon
Ctype
Dinterface
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'type' instead of 'interface' to define an interface.
Using 'implements' or 'on' incorrectly here.
2fill in blank
medium

Complete the code to make Human implement the Character interface.

GraphQL
type Human [1] Character {
  id: ID!
  name: String!
  totalCredits: Int
}
Drag options to blanks, or click blank then click option'
Aextends
Binherits
Cimplements
Don
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'extends' or 'inherits' which are not GraphQL keywords.
Using 'on' which is used in fragments, not type definitions.
3fill in blank
hard

Fix the error in the fragment to specify the correct type condition.

GraphQL
fragment characterDetails on [1] {
  id
  name
}
Drag options to blanks, or click blank then click option'
ACharacter
BHuman
CQuery
DMutation
Attempts:
3 left
💡 Hint
Common Mistakes
Using a concrete type like 'Human' limits the fragment to that type only.
Using 'Query' or 'Mutation' which are root types, not interfaces.
4fill in blank
hard

Fill both blanks to define a union type SearchResult that includes Human and Droid.

GraphQL
union SearchResult = [1] | [2]
Drag options to blanks, or click blank then click option'
AHuman
BCharacter
CDroid
DStarship
Attempts:
3 left
💡 Hint
Common Mistakes
Including interfaces like Character in unions is not allowed.
Using unrelated types like Starship if not intended.
5fill in blank
hard

Fill all three blanks to write a query that fetches a character by ID and returns fields based on the concrete type.

GraphQL
query getCharacter($id: ID!) {
  character(id: $id) {
    id
    name
    ... on [1] {
      [2]
    }
    ... on [3] {
      primaryFunction
    }
  }
}
Drag options to blanks, or click blank then click option'
AHuman
BtotalCredits
CDroid
Dheight
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up type names in fragments.
Using fields that do not exist on the specified type.