Skip to content

How to use Index signatures as types #1303

Answered by MichalLytek
lantos1618 asked this question in Q&A
Discussion options

You must be logged in to vote

You need to represent the object with dynamic keys as an array of key-value objects.

@ObjectType()
export class LabelValue {  
	@Field()
	label: string;
	
	 @Field()
    value: string;
}

@ObjectType()
export class Foo {    
	@Field(() => [LabelValue])
	labels: LabelValue[];
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lantos1618
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants