GraphQL - Resolvers
Given the following GraphQL schema and resolvers, what will be the output of the query
{ user { id name posts { title } } }?
type User {
id: ID!
name: String!
posts: [Post!]!
}
type Post {
title: String!
}
const resolvers = {
User: {
posts(parent) {
return postsData.filter(post => post.userId === parent.id);
}
}
};
const postsData = [
{ title: "Post 1", userId: "1" },
{ title: "Post 2", userId: "2" },
{ title: "Post 3", userId: "1" }
];