GraphQL mutations - unexpected end of document

I’ve been trying to use the graph QL mutation but I am getting a failure of

{'errors': [{'message': 'Unexpected end of document', 'locations': []}]}

I’m most interested in the vulnerability dismiss capability but for ease of discussion I’ve been able to reproduce it with the echoCreate mutation which is described as a endpoint test for mutations without actually modifying anything.

The mutation works in the graphql-explorer but does not work when I create the query using curl or python. I have been able to build/execute graphQL’s that use the query, but seems like all mutations that I’ve tried do not work.

My query looks like this:

        mutation = """
        {
            echoCreate(input:{ 
              clientMutationId: "blah3"
              messages: "blah"
              errors: "blah2"
            }) {
              errors
              echoes
              clientMutationId

            }        
        }
       """

This is the curl command I’m using:

curl  "https://<mydomain>/api/graphql" --header "Authorization: Bearer <MY_TOKEN>" --header "Content-Type: application/json" --request POST --data "{\"mutation\": \"mutation {echoCreate(input:{messages: \"blah\"}) {errors echoes} \"}"

Was able to figure this one out. Turns out the mutation needs to be buried inside of the query. it’s kind of strange to me as I would have though the mutation (write) would be at the same level as a query (read).

curl  "https://<mydomain>/api/graphql" --header "Authorization: Bearer <MY_TOKEN>" --header "Content-Type: application/json" --request POST --data "{\"query\": \"mutation {echoCreate(input:{messages: \"blah\"}) {errors echoes} \"}"