Gatsby: Use Playground instead of GraphiQl

Created on 17 Jan 2019  路  21Comments  路  Source: gatsbyjs/gatsby

Summary

Gatsby should use Prisma GraphQl Playground instead of GraphiQl for its Query Browser.

Motivation

After using the Prisma Playground for the last months, I can not go back to GraphiQl. To just list the pros/cons and after being motivated by @KyleAMathews on twitter to create an issue. I will try to be objective and focus on the benefits for Gatsby

Pros

  • 馃梻Tabs to save prior queries
  • 馃摉Query Browser easier to navigate back and forth
  • 鈿欙笍Customisation Options (for the editor)
  • 鈿涳笍Maintained by one of the biggest GraphQl providers for React and recommended by Apollo
  • 馃攺Tracing
  • 馃寫Dark Mode

Cons

  • New URL needs to be implemented, maybe only with a major version upgrade or both in parallel (/___playground)
  • People got used to GraphiQl

If you have any own Pros or Cons, please add them here. Maybe they will help the Gatsby make a more educated decision. If good ones are mentioned, I might edit the above list.

EDIT: I went ahead and created this plugin that will add a route at /___playground with the Prisma Playground. 馃槃

Most helpful comment

A PR adding it as an experimental feature has been merged. To use it update your version and add the environment variable GATSBY_GRAPHQL_IDE=playground to use it.

Have fun 馃憢馃徑

All 21 comments

I haven't tried the playground, is it that much different to get used to from GraphiQL as your cons suggest? Does it not support something you can do with GraphiQL, or work/behave in a very different way to do similar tasks?

I think that's a good change

@polarathene not really, but I added that point because people like to complain about change 馃槄

Hey :), it would be nice to have graphql-playground bundled with Gatsby. But first of all playground is made by Prisma. And if you want some new feature inside playground please create an issue. Playground supports theming and there could be even Gatsby theme, so it would fit more to whole Gatsby family.

@Huvik you are totally right, we are using it with Apollo and mixed them up haha
I will fix that.

@Saifadin I could see this being a plugin!

Should be easy to set up a new route in express onCreateDevServer

@sidharthachatterjee that is also a possible approach, that can be used in the meanwhile, as I think this would be at least minor version jump or even a major one.
To be frank I think for beginners to GraphQl the Playground might be easier to use. This is a very subjective viewpoint I know, but I stand by it 馃槤

if you want to use playground now you can checkout #4231 to start using it.

Sadly we have other priorities right now and don't see this as a blocking issue.

I would love for the gatsby team to consider using Playground and to discuss it. But for now I created this plugin that creates the /___playground route which can be used to query and navigate through the schema

https://github.com/Saifadin/gatsby-plugin-playground

It worked with multiple of my projects and I hope no issues arise :)

@Saifadin Would you like to add support for Playground in core? @freiksenet mentioned that Playground is better maintained than GraphiQL and we would love to accept a PR!

@sidharthachatterjee sure I can get to that 馃憣馃徑
Will make a PR soon-ish^^

@sidharthachatterjee follow-up question, should I stick with express-graphql and add a new route for the Playground or replace it with apollo-server-express?

I think we should stick with express-GraphQL and add a new route for the moment

@Saifadin I would suggest you to use graphql-playground-middleware-express, because this one receives most recent updates. And its kind of easy to implement it.

Yes, exactly. That's what I am using in gatsby-plugin-playground and I already added it.
Spoiler: It works, just need to fix some little stuff

Nice! I would really love to see some custom Gatsby purple theme for the playground. It would be a really nice addition.

Yes I agree!! Will try to add that 馃榿

If you need help hit me up!

A PR adding it as an experimental feature has been merged. To use it update your version and add the environment variable GATSBY_GRAPHQL_IDE=playground to use it.

Have fun 馃憢馃徑

There is also a gatsby plugin for Altair, in case anyone wants to spice things up a little bit more! 馃槃
https://www.gatsbyjs.org/packages/gatsby-plugin-altair-graphql/

Yes, exactly. That's what I am using in gatsby-plugin-playground and I already added it.
Spoiler: It works, just need to fix some little stuff

Works like a charm dude!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

3CordGuy picture 3CordGuy  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments

kalinchernev picture kalinchernev  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments

signalwerk picture signalwerk  路  3Comments