As a newcomer to coding and Typescript, I apologize for my limited knowledge. I am currently facing an issue where my application is unable to communicate with my API due to an error caused by the primary id key having a "?" symbol, like so:
export interface PartMaster {
id?: number;
}
Removing the "?" symbol leads to one error, while keeping it also results in a different error. Could this be related to something missing in GraphQL? Although I primarily work on the front end, I need to resolve this independently today, as my colleague who handles GraphQL is unavailable. Any guidance would be greatly appreciated.
Below is the code triggering the issue when the "?" symbol is present in the id:
computed: {
part(): PartMaster {
return {
partNumber: this.partNumber,
}
}
},
The error message states "property 'id' missing in type partNumber"
When the "?" symbol is included, the error message occurs at the following lines:
editRow(partMaster.id)
editRow(part.id)
Both partmaster.id and part.id are highlighted with the error message:
Argument of type 'number | undefined' is not assignable to parameter of type 'number'. Type 'undefined' is not assignable to type 'number'.