This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis
I'm jumping between several GraphQL APIs lately, and I was looking for a way to open the endpoints in GraphQL Playground quickly. So I dug into the source code and found that it registers a protocol handler (graphlql-playground
). The cool thing about it is that it handles headers like Authorization
, too.
To quickly open any GraphQL API in the playground, you can use the following URL:
graphql-playground://endpoint=ENDPOINT?headers={"Authorization": "Bearer AUTH_TOKEN"}
Because I spend a lot of time in the CLI, I also wrote myself a quick shell function to quickly open GraphQL Playground.
function open-gql-playground() {
local ENDPOINT=$1
local AUTH_TOKEN=$2
open "graphql-playground://endpoint=$ENDPOINT?headers={\"Authorization\": \"Bearer $AUTH_TOKEN\"}"
}
Happy querying!
Reply to Stefan
This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis
Stefan Judis | Sciencx (2020-07-20T22:00:00+00:00) GraphQL Playground offers a protocol handler (#tilPost). Retrieved from https://www.scien.cx/2020/07/20/graphql-playground-offers-a-protocol-handler-tilpost/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.