GraphQL Playground offers a protocol handler
Written by Stefan Judis
- Published at
- Updated at
- Reading time
- 1min
This post is part of my Today I learned series in which I share all my web development learnings.
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!
If you enjoyed this article...
Join 5.5k readers and learn something new every week with Web Weekly.
Reply to this post and share your thoughts via good old email.