'Typescript type { [k in string]: StuffItem } for NestJS GraphQL
I am trying to find out how to use { [k in string]: StuffItem } type in typescript in GraphQL in NestJS.
StuffItem:
export class StuffItem{
name: string;
price: number;
}
We already use { [k in string]: StuffItem } in our RestAPI, with the response like:
{
"order": {
"items": {
"5": { "name":"xxx", "price": 10 }
}
}
}
How should we decorate items in Order class to allow the same result?
@ObjectType
export class Order{
@Field(type => ???)
items: { [k in string]: StuffItem }
}
Thank you!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
