I use this package with my private graphql endpoint, it generates more than 130 files.
But the package generates the "TournamentQueryObject" class with some functions without params.
For example, the TournamentQueryObject->selectNameByLanguage() function should be selectNameByLanguage(string $lang)
It generates the query :
query {
tournaments() {
nameByLanguage
}
}
But I need the query:
query {
tournaments() {
en:nameByLanguage ( lang : "en" )
}
}
I think there is some uncompleted features in the package while parsing graphql schema, but I have an easy solution without breaking changes.
How to implement these features:
php:
->selectNameByLanguage()
->addPrefix('en')->addArguments(['lang' => 'en'])
Another example with the https://graphql-pokemon.now.sh endpoint
Can't generate a graphql query with the "new_id:id" prefix
query {
pokemon(name: "Pikachu") {
new_id:id
number
name
}
}
Can't generate a graphql query with the arguments
query {
pokemon(name: "Pikachu") {
new_id:id (argument_name: "argument_value")
number
name
}
}
php:
->selectPokemon((new RootPokemonArgumentsObject())->setName('Pikachu'))
->selectId()
->selectNumber()
->selectName();
Easy solution:
php:
->selectPokemon((new RootPokemonArgumentsObject())->setName('Pikachu'))
->selectId()
->addPrefix('new_id')->addArguments(['argument_name' => 'argument_value'])
->selectNumber()
->selectName();
The addPrefix() function adds the prefix to the last selection element.
The addArguments() function adds the arguments to the last selection element.
I have added these functions in the php-graphql-client pull request.