How to properly send a GraphQL update request using Axios

0 votes

I created an application using AWS Amplify, and I want to create an endpoint in an API function that will mutate a field in GraphQL. Since its a nodejs API function, I cannot use the recommended libraries from the AWS documentation which use ES6, since the functions can only use ES5. Therefore I need to use Axios.

I created a graphql query:

const query = /* GraphQL */ `mutation updatePublication($id: ID!, $keywords: String) {
                    updatePublication(id: $id, keywords: $keywords){
                      id
                      keywords
                    }
                  }`

Next, I created the Axios request based on this StackOverflow question.

const data = await axios.post(
        process.env.API_APPNAME_GRAPHQLAPIENDPOINTOUTPUT,
        {
          query: query,
          variables: {
              id: variableWithID,
              keywords: "updated keywords!"
          }
        },
        {
          headers: {
            'Content-Type': 'application/json',
            'x-api-key': process.env.API_APPNAME_GRAPHQLAPIKEYOUTPUT
          }
        }
    )

When I run the query, I get a status 200 from the server with the following errors:

  data: null,
  errors: [
    {
      path: null,
      locations: [Array],
      message: "Validation error of type MissingFieldArgument: Missing field argument input @ 'updatePublication'"
    },
    {
      path: null,
      locations: [Array],
      message: "Validation error of type UnknownArgument: Unknown field argument id @ 'updatePublication'"
    },
    {
      path: null,
      locations: [Array],
      message: "Validation error of type UnknownArgument: Unknown field argument keywords @ 'updatePublication'"
    }
  ]
}

Can anyone advise on what this means?

Jan 24, 2023 in AWS by Tejashwini
• 3,820 points
555 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In AWS

+2 votes
3 answers

How to send email to non-verified email address using AWS SES

While running in sandbox mode you can ...READ MORE

answered Jul 26, 2018 in AWS by Priyaj
• 58,090 points
8,473 views
0 votes
1 answer

How to upload to Dropbox and overwrite a file Using CURL

You need to use mode with parameter ...READ MORE

answered Aug 8, 2018 in AWS by Priyaj
• 58,090 points
4,500 views
0 votes
1 answer

How to download the latest file in a S3 bucket using AWS CLI?

You can use the below command $ aws ...READ MORE

answered Sep 6, 2018 in AWS by Archana
• 4,170 points
19,016 views
+1 vote
1 answer

How to issue a parsing json from case class using jackson?

Do you use jackson-module-scala or any other Scala-aware configuration ...READ MORE

answered Sep 26, 2018 in AWS by Priyaj
• 58,090 points
2,764 views
+1 vote
2 answers

How to read a csv file stored in Amazon S3 using csv.DictReader

The code would be something like this: import ...READ MORE

answered Oct 25, 2018 in AWS by Archana
• 5,640 points
53,580 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,678 views
0 votes
1 answer

AWS Lamda with Proxy Integration not recieving request parameters

The lambda proxy integration should pass through ...READ MORE

answered Sep 19, 2018 in AWS by Priyaj
• 58,090 points
714 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,224 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP