glesys / butler-graphql

An opinionated GraphQL package for Laravel.
MIT License
34 stars 5 forks source link

feat: extract fetching the schema #33

Closed mathieutu closed 3 years ago

mathieutu commented 3 years ago

Hi, I've extracted an getSchema methods, which allows to override it to get several scheme, merge them, or custom the way we get it generally.

Thanks.

wecc commented 3 years ago

Thanks for you PR @mathieutu!

I took the liberty of renaming the method schema() (to better match the existing ones), update the CHANGELOG and add a test. I'm looking forward to getting this merged soon!

wecc commented 3 years ago

@emil-nasso @ttrig can you please have a look at this?

mathieutu commented 3 years ago

Actually now I'm playing with extending/replacing the whole shema, maybe we can split that in a sdlSchemaString or something like that, and another true schema method which return the schema object.

    public function schema(): \GraphQL\Type\Schema
    {
        return BuildSchema::build($this->getSDLSchema(), [$this, 'decorateTypeConfig']);
    }
wecc commented 3 years ago

@mathieutu I'm thinking extendSchema(\GraphQL\Type\Schema): \GraphQL\Type\Schema, so you don't need to build everything (including resolving the schema content and appending decorateTypeConfig) from scratch. The default implementation would be an no-op just returning the provided schema.

wecc commented 3 years ago

Conflicts fixed and commits squashed in #40