Error when doing API.graphql update - `Unhandled Rejection (Error): Invalid AST Node: undefined`
See original GitHub issueDescribe the bug
This is what i was trying to do:
await API.graphql({ query: updateBlog, variables: { input } });
This is what i got:
I have no idea what this Unhandled Rejection (Error): Invalid AST Node: undefined
means and the error is very unhelpful.
To Reproduce
https://github.com/sw-yx/talk-react-summit-demo-cms
add this to updateBlog
:
return async function (newValues: Blog) {
const timestamp = new Date();
const newBlog: Blog = {
...newValues,
createdAt: oldValues.createdAt,
updatedAt: timestamp,
};
setBlogs([...blogs.filter((x) => x.id !== oldValues.id), newBlog]);
const { createdAt, updatedAt, ...input } = newBlog;
console.log({ input }); // i have checked that the input here should be valid
await API.graphql({ query: updateBlog, variables: { input } }); // the problem is here
};
}
Expected behavior
it should just work
What is Configured? If applicable, please provide what is configured for Amplify CLI:
-
Which steps did you follow via Amplify CLI when configuring your resources.
-
Which resources do you have configured?
- If applicable, please provide your
aws-exports
file:
- If applicable, please provide your
const awsmobile = { “aws_project_region”: “us-east-1”, “aws_appsync_graphqlEndpoint”: “https://hl5cqmuevvatjlsg7pidqllhpa.appsync-api.us-east-1.amazonaws.com/graphql”, “aws_appsync_region”: “us-east-1”, “aws_appsync_authenticationType”: “API_KEY”, “aws_appsync_apiKey”: “da2-ptzhxarenzdf7ljabwlkxbjdxu” };
export default awsmobile;
<details>
<summary><strong>Environment</strong></summary>
npx: installed 1 in 1.408s
System: OS: macOS Mojave 10.14.6 CPU: (8) x64 Intel® Core™ i7-8569U CPU @ 2.80GHz Memory: 65.03 MB / 16.00 GB Shell: 5.3 - /bin/zsh Binaries: Node: 12.18.0 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.7 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Browsers: Chrome: 85.0.4183.102 Firefox: 68.8.0 Safari: 13.1.2 npmPackages: @chakra-ui/core: ^1.0.0-rc.3 => 1.0.0-rc.3 @testing-library/jest-dom: ^4.2.4 => 4.2.4 @testing-library/react: ^9.3.2 => 9.5.0 @testing-library/user-event: ^7.1.2 => 7.2.1 @types/jest: ^24.0.0 => 24.9.1 @types/node: ^12.0.0 => 12.12.58 @types/react: ^16.9.0 => 16.9.49 @types/react-dom: ^16.9.0 => 16.9.8 aws-amplify: ^3.2.0 => 3.2.0 formik: ^2.1.5 => 2.1.5 react: ^16.13.1 => 16.13.1 react-dom: ^16.13.1 => 16.13.1 react-scripts: 3.4.3 => 3.4.3 typescript: ^4.0.2 => 4.0.2 npmGlobalPackages: @11ty/eleventy: 0.11.0 @aws-amplify/cli: 4.26.1-flutter-preview.0 @prisma/cli: 2.6.1 diff-so-fancy: 1.3.0 expo-cli: 3.21.5 generator-code: 1.2.19 netlify-cli: 2.53.0 npm: 6.14.7 vsce: 1.77.0 yo: 3.1.1
</details>
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (4 by maintainers)
Top GitHub Comments
i have discovered this is my fault - i have another function that is also called
updateBlog
and that was being shadowed unintentionally. sorry for the noiseThis issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server
*-help
channels or Discussions for those types of questions.