It would be nice if I could map input-object's to real PHP objects like I can do with Scalars.
MoneyInput:
type: 'input-object'
config:
description: 'Money'
fields:
currency:
type: 'Currency!'
amount:
type: 'String!'
I want to map this input to Money\Money object.
Hey! You should checkout the annotations branch and the related documentation.
Like creating input object with annotation and the arguments transformer to populate and validate automatically your input objects as PHP classes.
With the annotations, you have a map between GraphQL objects and PHP classes and it opens a new world of possibilities :)
@Vincz Thanks :) In this project we don't want to use annotations but just YAML for all configurations. Do you think it would be possible to create some kind of transformer between Input object to PHP code?
@ruudk Yes, you can still use the Argument transformers without annotations, but you will need to provide manually the PHP classes / GraphQL objects map. The rest should works just fine.
Do you think the Argument Transformer will be merged soon?
Hey @mcg-web, do you think we could merge the annotation branch into master now?
Yes we can, master is still under development.
done!
@ruudk Yes, you can still use the Argument transformers without annotations, but you will need to provide manually the PHP classes / GraphQL objects map. The rest should works just fine.
@Vincz Do you maybe have an example on how to achieve this? I don't get it.
for me this is also relevant, we do not use annotations. I would like some detailed example of how to do this.
@PartosK @ruudk
It's not possible to convert your YAML input-object types into PHP-objects. The ArgumentsTransformer is designed to work with types defined with annotations and assumes, that each of your GraphQL types is associated with a PHP class and tries to instantiate and populate it. Obviously your yaml types are not associated with php classes and there is no way to provide this information to the ArgumentsTransformer manually.
There is currently a feature in development, that will do exactly, what you need, but it won't be released until February/March.
Most helpful comment
done!