I am having trouble querying an enum from GraphQL in my Nest.js with GraphQL project. I keep getting an error message saying: "Enum 'TraitReportType' cannot represent value: 'EMBEDDED'".
I have tried using type:EMBEEDED, but it did not work. I also attempted to use try {} along with sub selection, but that also did not yield the desired result.
Here is how I defined my type:
@Expose()
@IsDefined()
@IsEnum(TraitReportType)
@ApiProperty({ enum: TraitReportType })
@Field(() => TraitReportType, { nullable: false })
type: TraitReportType;
Further defining the TraitReportType:
import { registerEnumType } from '@nestjs/graphql';
export enum TraitReportType {
LAYOUT = 'layout',
EMBEDDED = 'embedded',
}
registerEnumType(TraitReportType, {
name: 'TraitReportType',
description: 'Trait Report Type enum types',
});
In my query:
query EntityReportsQuery($id: ID!) {
entity(id: $id) {
id
secondaryId
reports {
key
name
description
icon {
type
component
name
size
source
}
type
layout
url
}
}
}
The data queried from the database looks like this:
{
"key": "A",
"url": "https://search.mevris.app/s/app-dashboards/app/dashboards#/view/204e17a0-a6df-11ed-ac80-b52d3b051a25?embed=true&_g=(filters:!(('$state':(store:globalState),meta:(alias:!n,disabled:!f,key:entityId.keyword,negate:!f,params:(query:%2203258d26-3914-4a19-b919-f8e88f3a68dd%22),type:phrase),query:(match_phrase:(entityId:%22${id}%22)))),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))&show-time-filter=true&hide-filter-bar=true",
"icon": {
"name": "current-ac",
"size": 2.7,
"type": "type icon",
"component": "component"
},
"name": "Current",
"type": "EMBEDDED",
"description": "Sum of Current"
}
I tried using type:EMBEEDED, but it did not work.