Replies: 1 comment 1 reply
-
There's no support in GraphQL Spec for dynamic keys while having type constraints. I would recommend converting @ObjectType()
class WidgetRecord {
@Field()
name: string;
@Field()
value: Widget;
} And then use is in @ObjectType()
class Box {
@Field([WidgetRecord])
widgetsByOwner: WidgetRecord[];
} An alternative and universal approach is to use JSON scalar - https://github.com/taion/graphql-type-json. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Supposed I have the following code:
How would I create a GraphQL type for
Record<string, Widget>
so that I can decoratewidgetsByOwner
with@Field
?Beta Was this translation helpful? Give feedback.
All reactions