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.

Mutation request that ends in Validation Error doesn't float error message to Promise's catch handler.

See original GitHub issue

I have the following client code running in the browser:

client.hydrated().then(function handleClientHydrated(client) {
      client.mutate({
        mutation: createStuff,
        variables: {
          listOfStuff: listOfStuff,
        },
      }).then(function handleMutationSuccess(data) {
        console.log(arguments);
        if (!data.listOfStuff) {
          throw new Error(`Server returned 200, but there was a validation error--and I can't see the error passed from the server via npm's require('aws-appsync').default module`);
        }
      }).catch(function handleMutationFailure() { // This never gets called.
        console.error('failure',arguments);
      });
    });

In the network pane, it looks like AWS AppSync returns Status Code 200 and a nice object with juicy error information.

Should that error information be passed to the success callback? How about the error callback? Should the error callback get called?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ArronHsiaocommented, Jul 25, 2018

I can use mutate function to successfully create new table, but can’t receive result back, something like

client.mutate({ mutation: mutations.createUser, variables: { … } }) .then(function logData(data) { console.log('results of mutation: ', data.data); }

just got

results of mutation: { createUser: null }

but the table creation is success

0reactions
elorzafecommented, Oct 16, 2018

We have fixed this on the latest release (aws-appsync@1.4.0) I will close the issue for now, but feel free to create a new issue if this problem persist.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error handling with promises - The Modern JavaScript Tutorial
The code of a promise executor and promise handlers has an "invisible try..catch " around it. If an exception happens, it gets caught...
Read more >
Full Stack Error Handling with GraphQL and Apollo
Request Errors occur when the client is at fault. There are 3 phases to a GraphQL query and client-caused errors may occur in...
Read more >
Element: <oj-input-text> - Oracle
Note: JET validation is designed to catch user input errors, and not invalid data passed from the server; this should be caught on...
Read more >
Validation and User Errors in GraphQL Mutations
In this blog post I would like to propose the pattern which you can use to handle user input validation and user errors...
Read more >
Resolvers | NestJS - A progressive Node.js framework
The @nestjs/graphql package, on the other hand, generates a resolver map ... a query handler to get the author object based on the...
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