Skip to content

Instantly share code, notes, and snippets.

@pesektomas
Last active April 8, 2020 09:10
Show Gist options
  • Save pesektomas/e50037434ebdd55837cb1ea6044d8de3 to your computer and use it in GitHub Desktop.
Save pesektomas/e50037434ebdd55837cb1ea6044d8de3 to your computer and use it in GitHub Desktop.
{
"query":
"{
categories { name }
}"
}
#!/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
> ./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