Complete the code to fetch the name field from a User type using an inline fragment.
query {
user(id: "1") {
... on [1] {
name
}
}
}The inline fragment specifies the type User to fetch the name field only if the object is of type User.
Complete the code to fetch the title field from a Post type using an inline fragment.
query {
node(id: "2") {
... on [1] {
title
}
}
}The inline fragment targets the Post type to fetch the title field.
Fix the error in the inline fragment to fetch the text field from a Comment type.
query {
node(id: "3") {
... [1] {
text
}
}
}The correct syntax for inline fragments includes the keyword on followed by the type name, like ... on Comment.
Fill both blanks to fetch the name from User and title from Post using inline fragments.
query {
node(id: "4") {
... on [1] {
name
}
... on [2] {
title
}
}
}The first inline fragment targets User to get name, and the second targets Post to get title.
Fill all three blanks to fetch name from User, title from Post, and text from Comment using inline fragments.
query {
node(id: "5") {
... on [1] {
name
}
... on [2] {
title
}
... on [3] {
text
}
}
}Each inline fragment targets the correct type to fetch the respective fields: name from User, title from Post, and text from Comment.