Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

448
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda