Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

447
Views
How to access @Args() in @ResolveField in nestjs

I have a query for getting projects from the DB which has args as shown below for filtering projects. How would I use the same args in the @resolveField for filtering form values of the project

@Query(() => [Project])
async getProjects(@Args() projectArgs: ProjectArgs) {
  return await this.projectsService.find(projectArgs);
}

@ResolveField("formValues", () => [FormValues])
async getFormValues(@Parent() project: Project) {
  const { id } = project;
  return await this.formsService.findValues({ projectId: id});
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I have faced this problem before and through thorough searching, I have come to the conclusion that the best and scalable way of doing this is to define the args for the field resolver itself. Here is how you do it

@ResolveField("formValues", () => [FormValues])
async getFormValues(@Args() projectArgs: ProjectArgs) {
  ..../////
}

This way you will have to pass the args just as you pass it in the parent query. Or you could leave them out if you don't want to filter the form values

There are other approaches that you can use. One of them is by setting the info as

@Query(() => [Project])
async getProjects(@Args() projectArgs: ProjectArgs, @Info() info) {
  info.variableValues.some_key = value
  return await this.projectsService.find(projectArgs);
}

But this won't scale and make it very tightly coupled

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!