Graphqlbundle: RFC: Split GraphiQL from the bundle

Created on 22 Sep 2017  路  6Comments  路  Source: overblog/GraphQLBundle

| Q | A
| ---------------- | -----
| Bug report? | no
| Feature request? | yes
| BC Break report? | yes/no
| RFC? | yes
| Version/Branch | 0.10.0

TODO

How to test

  • create a new symfony project: composer create-project "symfony/skeleton:^3.3" test-graphiql
  • add the repo in composer (there's no packagist yet):
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/renatomefi/OverblogGraphiQLBundle.git"
        }
    ],
  • install the bundle: composer require overblog/graphiql-bundle
  • register the route: config/routes/dev/graphiql.yaml:
overblog_graphiql:
    resource: "@OverblogGraphiQLBundle/Resources/config/routing.xml"
  • Install the OverblogGraphQLBundle: composer require overblog/graphql-bundle
  • For now (will be removed on 0.10) remove the graphiql route: rm config/routes/dev/graphql_graphiql.yaml
  • Run your local server and access /graphiql
  • In theory it's all configured and working :)
  • You might have errors if you don't have a proper schema

RFC

I was thinking about refactoring some part of the code bundle, when I did step into the GraphiQLController and saw an opportunity to use more DI instead of the container usage, this comes with a problem.
If I inject twig, when the SF app doesnt have it we are going to have a compile error, and that might be common since SF flex doesnt bring twig by default, and it`s only interesting when on development enviroment.

My idea was to somehow only enable the controller in case it's dev environment or if the graphiql route is enable, which is when it makes sense, but when I was thinking about it the idea of splitting the bundle sounded better.

The GraphiQL bundle would be configurable with:

  • endpoint
  • GraphiQL, react and fetch JS libraries versions

Some other notes:

  • The default configuration would auto-wire to OverblogGraphQLBundle.
  • It would also make possible to use it standalone
  • And also possible to use it with other graphql php libraries
  • A new flex recipe for only graphiql will be added
  • This bundle will require Twig explicitly

Is this a viable idea?

enhancement

Most helpful comment

Good idea, I'm closing this one then!

https://media.giphy.com/media/l3vRaWnqG3gOZ8lsk/giphy.gif

All 6 comments

Yes this look good to me. More the bundle get light more it will be easy to maintain...

I have a WIP here: https://github.com/renatomefi/OverblogGraphiQLBundle
Not working yet, please don't contribute yet since I'm changing the code all the time

Flex recipe for the GraphiQL bundle is working: symfony/recipes-contrib#127

  • composer create-project "symfony/skeleton:^3.3" flex-graphiql-recipe
  • SYMFONY_ENDPOINT=https://symfony.sh/r/github.com/symfony/recipes-contrib/127 composer req --dev "overblog/graphiql-bundle:^0.1.0-BETA1"
  • php -S 127.0.0.1:8000 -t public
  • http://127.0.0.1:8000/graphiql

Of course this is without GraphQLBundle so nothing to see, so you can proceed installing it as well :)

  • SYMFONY_ENDPOINT=https://symfony.sh/r/github.com/symfony/recipes-contrib/123 composer req "overblog/graphiql-bundle:^0.10.0-ALPHA1"

@mcg-web should we put a to-do for when we have a alpha tag?

no need alpha to start trying this I think but yes we can add a date to release a alpha version, maybe we should add information directly on milestone?

Good idea, I'm closing this one then!

https://media.giphy.com/media/l3vRaWnqG3gOZ8lsk/giphy.gif

Was this page helpful?
0 / 5 - 0 ratings