overblog / GraphQLBundle

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

Types configuration post processing #1025

Closed mathroc closed 2 years ago

mathroc commented 2 years ago
Q A
Bug report? no
Feature request? yes?
BC Break report? kinda
RFC? no
Version/Branch 0.14 / 0.15

Hi!

I'm upgrading from 0.13 and I'm wondering how to do something I've been doing:

The goal is to create a Query.IsGranted object containing one field for each existing mutation. and have the resolver of this new field return the value of the mutation access field. This allows the frontends to ask if the current user is allowed to perform a mutation or not. In 0.13 I'm doing this by overriding the Overblog\GraphQLBundle\Config\Processor but I can't do this in 0.14+ because it's not injected TypeGenerator anymore. And I don't know how to achieve the same thing.

Is it still possible?

I think my goal is to update the $typeConfigs given to the TypeGenerator by somehow overriding %overblog_graphql_types.config% but I was not able to find how


alternative: I also tried to create a field resolver and using it to create the query.IsGranted field but I don't think I can access the fields in Mutation from here (and it's unclear this could work given it would need to be resolved only after all mutations have been configured)

mathroc commented 2 years ago

found a way to override the %overblog_graphql_types.config% with a compiler pass :ok: