mghoneimy/php-graphql-client

Do you support Enum Types?

Closed this issue · 4 comments

Hello,

I am currently using this package and currently trying to connect to a graphQL client.

I have this setArguments which the types is in ENUM. below:

->setArguments([ 'types' => 'GENERAL', 'languages' => ["en"]])

I tried to sent the request to the graphQl client but I always get this message.

"message": "Expected type DescriptionType!, found \"GENERAL\". Did you mean the enum value GENERAL?

I just want to ask how do you send Enum Values in a grapql client using setArguments or do i need to use the setVariables?
Can you please show an example?

Thank you!

Hello @jbalbert , I will look into this tomorrow and provide you with an example.

Hi @mghoneimy , Thank you very much for your response that would be a really big help.

@jbalbert Generally, to write raw text in the query (an example would be a non-string ENUM type, or an input object) you would use the RawObject class provided in this library. Here's your example:
->setArguments([ 'types' => new RawObject('GENERAL'), 'languages' => ["en"]])

Hope this helps :)

Hello @mghoneimy ,

I just tested it and it now works.

Thanks for your help! :)