Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a union type named SearchResult.
GraphQL
union SearchResult = [1] | Book | Author Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a type not defined in the schema.
Forgetting to separate types with |.
✗ Incorrect
The union type SearchResult includes Movie, Book, and Author types.
2fill in blank
mediumComplete the query to search for a SearchResult by ID.
GraphQL
query { search(id: 1) { ... on [1] { title } ... on Author { name } } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a type not in the union.
Missing the inline fragment syntax.
✗ Incorrect
The query uses an inline fragment on Book to get the title field.
3fill in blank
hardFix the error in the union type definition by completing the code.
GraphQL
union SearchResult = Book | [1] | Author Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including scalar types in union definitions.
Using types not defined as objects.
✗ Incorrect
Union types can only include object types, not scalar types like String or Int.
4fill in blank
hardFill both blanks to complete the query using inline fragments for SearchResult.
GraphQL
query { search(id: 2) { ... on [1] { title } ... on [2] { name } } } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using types not in the union.
Forgetting to use inline fragments.
✗ Incorrect
The query uses inline fragments on Book and Author to get their respective fields.
5fill in blank
hardFill all three blanks to define a union and query it correctly.
GraphQL
union SearchResult = [1] | [2] | Author query { search(id: 3) { ... on [3] { title } ... on Author { name } } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using scalar types in union.
Mismatch between union types and query fragments.
✗ Incorrect
The union includes Director, Movie, and Author. The query uses an inline fragment on Movie to get the title.