GraphQL Upsert Syntax

I’m trying to get the syntax down for running an Upsert via curl. I’m using the Upsert guidance on this page: /

My Upsert attempt looks like:

curl -H "Content-Type: application/json" localhost:8080/mutate/?commitNow=true -XPOST -d '{
  "query": "mutation($traveler: [AddTravelerInput!]!) {addTraveler(input: $traveler, upsert: true) {traveler {user_id countries_visited {country_code}}}}",
  "variables": { "traveler": {"user_id": "1c395a9f", "countries_visited": { "country_code": "US"}}
}' | jq

Resulting error:

  "errors": [
      "message": "while lexing mutation($traveler: [AddTravelerInput!]!) {addTraveler(input: $traveler, upsert: true) {traveler {user_id traveler_countries_visited {country_code}}}} at line 1 column 8: Unrecognized character inside mutation: U+0028 '('",
      "extensions": {
        "code": "ErrorInvalidRequest"
  "data": null
What am I doing wrong?

Thanks in advance!

You are trying to send a GraphQL mutation to the DQL mutate endpoint.

This may help:

1 Like

Thank you! Pointing it to the correct endpoint helped resolve the lexing issue and from there just had to tweak a couple things to get it working. And thanks for the link!

1 Like

Hello there! Could you share the last version as an example? Thanks

curl -X POST "http://localhost:8080/graphql" -H "Content-Type: application/json" -d '{
"query": "mutation($vtraveler: [AddTravelerInput!]!) {addTraveler(input: $vtraveler, upsert: true) {traveler {user_id countries_visited {country_code} }}}",
"variables": {"vtraveler": {"user_id": "1c395a9f", "countries_visited": {"country_code": "GB"} }}}'