I have a methodsfragment.ts file that is autogenerated for a graphql fragment query. I used the command npm run generate --graphql.
In the query we have a interface formElement which can be a input, select, radio etc based on the data. The data looks something like this:
inputs[{
formElements:{
identifier: "first_name_input",
label: "First name",
placeholder: ""
}
},{
formElement:{
identifier: "select_year",
label: "year",
options:["1999","2000", "2001"]
}}]
in my methodsFragments.ts I have the definition of formElements something like:
export type inputRows_formElements = inputRows_formElements_firstNameInputField | inputRows_formElements_yearDropdown;
type firstNameInputField {
identifier: string!;
label: string!;
placeholder: string!;
}
type yearDropdown {
identifier: string!;
label: string!;
options: string[];
}
when I am trying to access data, I do something like:
methods.map(formEle) =>{
switch(formEle.identifier):
case "select_year" :
console.log("options length" + formEle.options); // at this line i get the error
}
The error message is: "Property options does not exist on type inputRows_formElements".I am not sure how to resolve this error.