mghoneimy/php-graphql-client

Multiple Queries in one QueryObject

Closed this issue · 7 comments

Hi,

would it be possible to add the possibility to have multiple queries within one QueryObject?
Our API enables us to fetch multiple queries at once like this:

            query ($where:PeopleWhereInput, $orderBy:PeopleOrderByInput, $start:Int, $length:Int, $locales:[Locale!]!){
                peoples (
                    where:$where,
                    orderBy:$orderBy
                    first:$length
                    skip:$start
                    locales:$locales
                ) {
                    id
                    displayName
                    createdAt
                    imageTemp
                    creator
                    stage
                    emailAddress
                    phoneNumber
                    company
                    peopleType
                    locale
                    slug
                }
                peoplesConnection{aggregate{count}}
                results: peoplesConnection(
                    where:$where,
                    orderBy:$orderBy
                ){aggregate{count}}
            }

Maybe it is possible already and I just didn't get it.

@chnshure Hello,
Unfortunately it's not possible as of now to support multiple field selections in the same query, this is change scheduled for the next major release.
You can still run your query using this client though through running string queries on the server. You can refer to this section for that
https://github.com/mghoneimy/php-graphql-client#running-raw-queries.

Thank you!

Hey @mghoneimy, what is the status on this? When is the next scheduled major release? Would like to see an enhancement as this.

PS. Thanks for making this package, was exactly what i was searching for. Only this 'enhancement' is missing for my use case.

@jeroenhekihenk I initially planned this release to be somewhere April, but now that I see that more people are asking for this, I can either move it sooner to March, or I can try to create a workaround to add support for this in a minor release and push the major release down the road.
I'll see what I can do keep you updated.

And I'm really glad you found this package useful, that's always great to hear from people in the community 😄

Hi @jeroenhekihenk ,
I have taken a look at the changes needed today and decided that this will need breaking changes that will require a major version bump.
I will start working on the new changes in tye next few weekends, and hopefully, will have this issue close in v2.0 to be released mid-late April.

Hey @mghoneimy,

Been a while since you heard from me, but i have to ask, what is the status of this 'feature request' ? I've been using this package for a while now and notice that i need the feature to do 'double' queries at the same time.

Hi @jeroenhekihenk ,

Unfortunately, because of everything going on around us I wasn't able to start this on its planned time, I apologize for the delay. I expect to be able to allocate time for this during this weekend and the following week. Hopefully I should be able to update you on the status of the feature in a few days.

Thank you!

@chnshure @jeroenhekihenk
The feature has been successfully implemented and released on v1.5.
I was able to find clean way to do this without breaking backward compatibility.
You can now run multiple queries under one Query or QueryBuilder object.
Please refer to these sections of the documentation for help
https://github.com/mghoneimy/php-graphql-client#multiple-queries
https://github.com/mghoneimy/php-graphql-client#the-full-form
https://github.com/mghoneimy/php-graphql-client#the-full-form-1