I’m using Apollo Federation with NestJS.
I like to get GraphQLResolveInfo in ResolveReference.
I tried to put @Info() decorator in resolveReference arguments.
The console.log shows some GraphQLResolveInfo data, but ref is undefined.
How can I get both of ref and GraphQLResolveInfo in ResolveReference?
# Service 1
@Resolver(() => JobCategory)
export class JobCategoryResolver {
constructor(
private jobCategoryService: JobCategoryService,
) {}
@ResolveReference()
resolveReference(
ref: { __typename: string; id: string },
@Info() info: GraphQLResolveInfo,
) {
console.log(info) // can see some GraphQLResolveInfo data;
console.log(ref) // undefined;
return this.jobCategoryService.jobCategory({
where: { id: Number(ref.id) },
});
}
}
# Service 2
@ResolveField(() => JobCategory)
jobCategory(@Parent() jobCategoryTag: JobCategoryTag) {
return {
__typename: 'JobCategory',
id: Number(jobCategoryTag.jobCategoryId),
};
}