question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when doing API.graphql update - `Unhandled Rejection (Error): Invalid AST Node: undefined`

See original GitHub issue

Describe the bug

This is what i was trying to do:

await API.graphql({ query: updateBlog, variables: { input } });

This is what i got:

image

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:

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:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

11reactions
sw-yxcommented, Sep 15, 2020

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 noise

0reactions
github-actions[bot]commented, Jul 2, 2022

This 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid AST Node: {"input":"** } on graphql mutation (Amplify ...
I created all items and then I tried to delete them but I failed especially on PostEditor. There is a mutation to delete...
Read more >
Troubleshooting and Common Mistakes - AWS AppSync
This section discusses some common errors and how to troubleshoot them. Incorrect DynamoDB Key Mapping. If your GraphQL operation returns the following ...
Read more >
Full Stack Error Handling with GraphQL and Apollo
If networkError is present in your response, it means your entire query was rejected, and therefore no data was returned. For example, the ......
Read more >
graphql/language
The graphql/language module is responsible for parsing and operating on the GraphQL language. ... A general-purpose visitor to traverse a parsed GraphQL AST...
Read more >
type-graphql/Lobby - Gitter
I'm getting (node:308) UnhandledPromiseRejectionWarning: Error: Unable to infer GraphQL type from TypeScript reflection system. You need to provide explicit ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found