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

158
Vistas
How to define the Graphql type for complex array

I am having a headache about defining the correct return types for this complex array I am returning via Graphql. I am also using the Nest.JS framework.

Here is my data:

[
 [ { Id: '1' }, [ [ { x: '01-02-2021', y: 12345 } ] ] ],
 [ { Id: '172' }, [ [Object], [Object] ] ],
 [ { Id: '173' }, 
  [
  [Object], [Object], [Object], [Object],[Object], [Object], [Object], [Object],
  [Object], [Object], [Object], [Object],[Object], [Object] 
  ]
 ]
]

This is the Class I am trying to return, as [ Grouped ] for the resolver.

@ObjectType()
export class Grouped {
  Id: string;
  SumPerDay: SumPerDay[];
}

@ObjectType()
class SumPerDay {
  x: string;
  y: number;
}

This is however, returning null for both id and SumPerday.

Any thoughts about this would be welcome!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I solved it by adding the types.

So instead of returning the above array, I slightly changed the returning data into :

    "Grouped": [
  {
    "Id": "1",
    "_data": [
      {
        "x": "Thu Sep 30 2021",
        "y": 0.02
      }
    ]
  },
  {
    "Id": "172",
    "_data": [
      {
        "x": "Mon Oct 04 2021",
        "y": 2327.7599999999998
      },
      {
        "x": "Wed Oct 06 2021",
        "y": 172.91000000000003
      }
    ]
  },
]

Now it is working.

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