Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when clicking Edit button #12

Open
floatpc opened this issue Jun 15, 2020 · 7 comments
Open

Error when clicking Edit button #12

floatpc opened this issue Jun 15, 2020 · 7 comments

Comments

@floatpc
Copy link

floatpc commented Jun 15, 2020

When I click Edit I keep getting INTERNAL_SERVER_ERROR.
[GraphQLError: Variable "$id" got invalid value "2"; Expected type Int; Int cannot represent non-integer value: "2"]
As a result the page says 'Issue with ID 2 not found'.
In every Chapter I get this. I'm in Chapter 11 now. The code is from the web site.

@vasansr
Copy link
Owner

vasansr commented Jun 16, 2020

It could be that in your database, the record has the string "2" instead of the number 2 in the _id field. Please try and clear the collection and re-initialize, and it should work, if that is the case.

@dtrhieu
Copy link

dtrhieu commented Jun 16, 2020

I am in Chapter 9, Nested Routes and I have also the similar error when clicking on button Select.
INTERNAL_SERVER_ERROR: Variable "$id" got invalid value "2"; Expected type Int. Int cannot represent non-integer value: "2".

I have tried that quick fix for that issue in IssueDetail.jsx
change
const data = await graphQLFetch(query, { id });
to
const data = await graphQLFetch(query, { id: parseInt(id) });

@vasansr
Copy link
Owner

vasansr commented Jun 17, 2020

What is the version of apollo-server-express you have installed? If it is not 2.3.x, it could be the reason.

@dtrhieu
Copy link

dtrhieu commented Jun 17, 2020

What is the version of apollo-server-express you have installed? If it is not 2.3.x, it could be the reason.

Thanks for your response, I'm using apollo-server-express v 2.13.0, but I've tried 2.3.x from Github and it produced the same error. Since Id is an integer, I think it should be sent to graphQLFetch variable with a parseInt(id).

For your reference, this is the file in question
https://github.com/vasansr/pro-mern-stack-2/blob/09.06-nested-routes/ui/src/IssueDetail.jsx

@TinMiner
Copy link

I too have the same problem. My apollo-server-express is 2.3.1 and all my ids on mlab are definitely of the int kind. The other functions using the id seem to work like delete and restore so its quite baffling, otherwise great stuff.

@thomascarpenter21
Copy link

Chap 10: Edit Form - I came across the same error message. I used the same solution as above on IssueEdit.jsx to resolve the error message.
Original code: const data = await graphQLFetch(query, { id });

New code: const data = await graphQLFetch(query, { id: parseInt(id) } );

@siricoa94
Copy link

siricoa94 commented Aug 10, 2020

Change

"const data = await graphQLFetch(query, { id } );"

To

"const data = await graphQLFetch(query, { id: parseInt(id) });"

Do this inside IssueEdit.jsx as well as IssueDetail.jsx in the async loadData() and this should fix it for you as it did for myself as noted above in reference to dtrhieu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants