pimcore / data-hub

Data delivery & consumption platform for Pimcore.
Other
125 stars 107 forks source link

Custom queries #172

Closed bramstroker closed 4 years ago

bramstroker commented 4 years ago

I was searching for a way to implement a custom GraphQL query which have some extra arguments and a custom resolver, but this seems not possible.

There is some event dispatched QueryEvents::PRE_BUILD before all the build in queries are registered, however I cannot alter the $config there as it is not passed by reference to the event object.

Also in the WebserviceController a new instance of QueryType is created without using any DI, which is really bad design practice. Better would be to have some factory object, ie QueryTypeFactory which is passed as a dependency to the webservice controler and is responsible for the creation of the query type.

Do you have a solution for my use case?

dvesh3 commented 4 years ago

@bramstroker can you please create a separate issue? thanks!

Also in the WebserviceController a new instance of QueryType is created without using any DI, which is really bad design practice. Better would be to have some factory object, ie QueryTypeFactory which is passed as a dependency to the webservice controler and is responsible for the creation of the query type.

weisswurstkanone commented 4 years ago

there is a sample about adding mutations, adding a query should work in a similar way.

https://github.com/pimcore/data-hub/blob/master/doc/graphl/AddCustomMutations.md

weisswurstkanone commented 4 years ago

also added a sample for custom queries:

https://github.com/pimcore/data-hub/blob/master/doc/graphl/AddCustomQuery.md

bramstroker commented 4 years ago

Tyvm for the fast resolution! Will try to implement next week when I work in the project again. Also had two type errors when trying to get the graphql API working. Will create a PR with the fix.