[Vuejs]-Property 'id' is missing in type {`id`} using GraphQL and Typescript

0👍

This question really needs more details, including the sections where the editRow function is defined and where your GraphQL query is called, and the text of the error when id is not marked as optional. However, I don’t yet have enough reputation to comment so will address this in an answer instead.

With the information given, here is what I can guess:

  • The last error messages that you give (Argument of type 'number | undefined' is not assignable to parameter of type 'number'. Type 'undefined' is not assignable to type 'number'.) are likely because editRow expects an argument of type number. By markingid as optional, you indicate that it may sometimes be undefined. Either don’t mark it as optional, or make editRow accept number | undefined and handle the undefined case in code.
  • In the case where you remove the "?" from id, what I would check first is that your GraphQL query does in fact request the id field. The point of GraphQL is to only request what you need so it is possible that your coworker has not added this field to the request. If it’s not that, I wouldn’t be able to help without the extra details mentioned above.

Leave a comment