Skip to content

Instantly share code, notes, and snippets.

@dabit3
Created September 17, 2020 15:28
Show Gist options
  • Save dabit3/52a86fe36816bce5e9d7f416376943d6 to your computer and use it in GitHub Desktop.
Save dabit3/52a86fe36816bce5e9d7f416376943d6 to your computer and use it in GitHub Desktop.
GraphQL requests using CURL
# query
curl \
-X POST \
-H "x-api-key: xxx-xxxx" \
-H "Content-Type: application/json" \
-d '{ "query": "query { listUsers { name } }" }' \
https://app-id.appsync-api.us-east-1.amazonaws.com/graphql
# mutation with variables
curl \
-X POST \
-H "x-api-key: xxx-xxxx" \
-H "Content-Type: application/json" \
-d '{ "query": "mutation($user: UserInput!) { createUser(user: $user) { name location id } }" ,
"variables": {
"user": {
"name": "Nader Dabit",
"location": "United States",
"id": "001"
}
}
}' \
https://app-id.appsync-api.us-east-1.amazonaws.com/graphql
@nadnosliw
Copy link

This is great, thanks. I previously found it a bit of a mystery knowing how to pass data into a request but seeing it in curl makes a lot of sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment