GraphQL Playground offers a protocol handler (#tilPost)

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). Th…


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


Print Share Comment Cite Upload Translate
APA
Stefan Judis | Sciencx (2022-12-09T16:23:41+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/.
MLA
" » GraphQL Playground offers a protocol handler (#tilPost)." Stefan Judis | Sciencx - Monday July 20, 2020, https://www.scien.cx/2020/07/20/graphql-playground-offers-a-protocol-handler-tilpost/
HARVARD
Stefan Judis | Sciencx Monday July 20, 2020 » GraphQL Playground offers a protocol handler (#tilPost)., viewed 2022-12-09T16:23:41+00:00,<https://www.scien.cx/2020/07/20/graphql-playground-offers-a-protocol-handler-tilpost/>
VANCOUVER
Stefan Judis | Sciencx - » GraphQL Playground offers a protocol handler (#tilPost). [Internet]. [Accessed 2022-12-09T16:23:41+00:00]. Available from: https://www.scien.cx/2020/07/20/graphql-playground-offers-a-protocol-handler-tilpost/
CHICAGO
" » GraphQL Playground offers a protocol handler (#tilPost)." Stefan Judis | Sciencx - Accessed 2022-12-09T16:23:41+00:00. https://www.scien.cx/2020/07/20/graphql-playground-offers-a-protocol-handler-tilpost/
IEEE
" » GraphQL Playground offers a protocol handler (#tilPost)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2020/07/20/graphql-playground-offers-a-protocol-handler-tilpost/. [Accessed: 2022-12-09T16:23:41+00:00]
rf:citation
» GraphQL Playground offers a protocol handler (#tilPost) | Stefan Judis | Sciencx | https://www.scien.cx/2020/07/20/graphql-playground-offers-a-protocol-handler-tilpost/ | 2022-12-09T16:23:41+00:00
https://github.com/addpipe/simple-recorderjs-demo