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

156
Views
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 answers
Answer question

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 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!