I have parent schema in graphql that built with apollo libraries apollo-server
and graphql-tools
that delegates subqueries to remote graphql schema.
For example the query below delegate the subquery of User.booking to the remote schema and it's working well.
const resolvers = {
User: {
bookings: (parent, args, context, info) => {
return info.mergeInfo.delegateToSchema({
schema: subschema,
operation: 'query',
fieldName: 'bookingsByUser',
args: {
userId: parent.id,
},
context,
info,
});
},
},
};
My question is how I can send the subquery of User.books from another resolver (in my case one of his parents resolver - Library) to the remote schema.
From the docs of apollo the function uses the info object in order to extract the wanted subquery:
info: GraphQLResolveInfo
GraphQL resolve info of the current resolver. Provides access to the subquery that starts at the current resolver.