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 Updates
APA

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/

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 ,<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 ]. 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 . 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: ]
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/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.