Created
September 17, 2020 15:28
-
-
Save dabit3/52a86fe36816bce5e9d7f416376943d6 to your computer and use it in GitHub Desktop.
GraphQL requests using CURL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.