Using type-graphql I am trying to build an entry-point that returns me a List entity with its meta info like name, description, etc. and also a computed field content, that supposed to contain entities added to the list. The entry-point must have pageNumber property that should be taken into account when returning the content.
How can I pass this property from the List entity resolver down to the content field resolver?
There is @Info decorator that seems to have this information but it does not look like it is supposed to be used for this purpose.
@Resolver(() => List)
export class MyListResolver {
@Query(() => List, { nullable: true })
async list(
@Arg('id') id: number,
@Arg('pageNumber', { nullable: true }) pageNumber: number,
): Promise<List | null> {
// Returns list's info
return await List.findOne(id) || null;
}
@FieldResolver(() => [ListEntity])
async content(@Root() list: List): Promise<ListEntity[]> {
// How do I access `pageNumber` here so I could return only the requested page of content?
return listsContentLoader.load(list.id);
}
}