overblog / GraphQLBundle

This bundle provides tools to build a complete GraphQL API server in your Symfony App.
MIT License
782 stars 221 forks source link

Be compatible with Symfony Flex #192

Closed renatomefi closed 6 years ago

renatomefi commented 6 years ago
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Version/Branch 0.9.*

Hello,

During the past few days I've been doing some work to make this bundle compatible with symfony flex, the related PRs are:

186 #187 #191

After that I was able to install the bundle easily on it, now I have a PR on symfony flex, please check it: https://github.com/symfony/recipes/pull/183 Edited: Check https://github.com/symfony/recipes-contrib/pull/85 for progress

Please check if it's accordingly to the bundle, I've added configuration for the routes and now it should work out of the box.

Also, releasing a new tag will help the process, since the recipes must determine the minimal version for the package

mcg-web commented 6 years ago

auto_discover is not commit yet so you should remove it. it fails because Query doesn't exist. The user must define a Query before using it, this is normal behavior.

renatomefi commented 6 years ago

I've defined it and removed the auto discover, that's why it's a bit weird :/

mcg-web commented 6 years ago

Yes i agree but it is the same for doctrine, you can't use an entity without declaring it before. Leave "query: ~" and finish recipe by pointing to this page https://github.com/overblog/GraphQLBundle/blob/master/Resources/doc/definitions/index.md

renatomefi commented 6 years ago

I've got it to work like this:

overblog_graphql:
    definitions:
        schema:
            query: Query
        mappings:
            types:
                -
                    type: yaml # [ yaml, xml ] this is required right now but will accept null in future
                    dir: "%kernel.project_dir%/config/graphql"

query: ~ or schema: ~ doesn't work.

I'll put the Hello World and the docs page is already in the post install txt, so then it should be all good

renatomefi commented 6 years ago

@mcg-web Damn, we have an issue: https://symfony.sh/r/github.com/symfony/recipes-contrib/85

screenshot from 2017-09-26 15-50-29

mcg-web commented 6 years ago

this query.types.yaml doesn't work ?

renatomefi commented 6 years ago

We're required to use underlines so Query_types.yaml

mcg-web commented 6 years ago

so this should also be configurable... I'm also adding this.

renatomefi commented 6 years ago

@mcg-web thanks for submitting the fix, I've just tried again and I failed to get it working out of the box:

SYMFONY_ENDPOINT=https://symfony.sh/r/github.com/symfony/recipes-contrib/85 composer req cli:^3.3 webserver:^3.3 twig:^3.3 overblog/graphql-bundle:0.9.x-dev
renatomefi commented 6 years ago

Oh wait, for some reason I got the old graphql configuration file, might be cache somewhere

renatomefi commented 6 years ago

@mcg-web works perfectly! :)

The only problem I'm having is indeed with the recipe cache, are you having the same?

renatomefi commented 6 years ago

This cache thing is crazy, I've tried re-pushing everything and cleared my whole composer cache but I'm getting an old version of the recipe, I think I'll close and re-open the PR

There we go: Now it works perfectly and out of the box, hello world and etc: https://github.com/symfony/recipes-contrib/pull/94

mcg-web commented 6 years ago

thank you @renatomefi, I'll try it later :+1:

mcg-web commented 6 years ago

It works perfectly but we should find a way to remove graphiql requirement and example. I don't really have idea of how to do that right now

renatomefi commented 6 years ago

@mcg-web I think the best we can do is just point the user to the docs, or do you see other solutions?

mcg-web commented 6 years ago

Right now this is the best solution, we should also add a .gitignore (.gitkeep) to graphql types dir. Maybe in v0.10 we will find a better solution. I'm going to realese v0.9. So we can start working on the new version. Thanks for the help on flex.

renatomefi commented 6 years ago

@mcg-web I removed the default query, pointing the users now to https://github.com/overblog/GraphQLBundle/blob/master/Resources/doc/definitions/index.md

Although I'm thinking about making a symfony flex post-installation doc page, but it can be done later

mcg-web commented 6 years ago

Thanks @renatomefi