Last active
April 8, 2020 09:10
-
-
Save pesektomas/e50037434ebdd55837cb1ea6044d8de3 to your computer and use it in GitHub Desktop.
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": | |
"{ | |
categories { name } | |
}" | |
} |
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
#!/bin/bash | |
QUERY=$(<"$1") | |
if [ $# -eq 2 ] | |
then | |
accessToken=$(curl -X POST http://127.0.0.1:8000/graphql/ -H "Content-Type: application/json" -d '{"query": "mutation {Login(input: {email: \"\", password: \"\"}) {accessToken}}"}' | jq '.data.Login.accessToken')| sed -e 's/^"//' -e 's/"$//' | |
curl -X POST http://127.0.0.1:8000/graphql/ -H "Content-Type: application/json" -H "Authorization: Bearer $accessToken" -d "$(echo $QUERY)" | |
else | |
curl -X POST http://127.0.0.1:8000/graphql/ -H "Content-Type: application/json" -d "$(echo $QUERY)" | |
fi |
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
> ./sendQuery category.json | |
> ./sendQuery category.json | jq '.data' | |
> ./sendQuery category.json auth | |
> ./sendQuery category.json auth | jq '.data' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment