-
Notifications
You must be signed in to change notification settings - Fork 225
Does somebody have experience with converting YAML definitions to PHP classes?
I want to do this in an automated way as we have hundreds of them.
All reactions
Yaml types are always converted to php classes for a performance purpose. You can use command graphql: compile to generate them on demand.
Replies: 1 comment 8 replies
Yaml types are always converted to php classes for a performance purpose. You can use command graphql: compile to generate them on demand.
All reactions
@ruudk this bundle is just a wrapper for webonyx/graphql-php and it basically just generates PHP Types for you from YAML, Annotations or GraphQL SDL. The generated classes are Symfony services. That means that you can just take the generated PHP classes and use them as your source (as you assumed). Well, technically these classes are already used as your sources, so the only thing you have to do is just to move them from the output folder somewhere alse and make them services and that's it. The GraphQLBundle will use these classes automatically. Here are some examples: #683
All reactions
@murtukov Thanks, I tried it and copied all the compiled PHP files into my src directory, but I still notice that the bundle takes all them and compiles them again (same output, except namespace) to my defined cache_dir. Why does it have to do that? I just want to reference all my code from the src directory, without compilation phase.
All reactions
I think I solved it:
'use_classloader_listener' => false, 'auto_compile' => false, 'show_debug_info' => '%kernel.debug%', 'config_validation' => false, 'mappings' => [ 'auto_discover' => [ 'root_dir' => false, 'bundles' => false, 'built_in' => false, ], ],
All reactions
@ruudk when you are in dev environment it always recompiles your php types from YAML, Annotations etc. In prod mode it does it only once, until you clear the cache.
The 'auto_compile' => false option disables the autocompilation completely. You don't have to set any other options to disable it.
All reactions
-
👍 1
Thanks for the help. I was able to convert all my YAML configs to PHP and disable auto_compile. 🚀