Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

449
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda