thecodingmachine/graphql-controllers

Feature request - Allow usage of enums

Opened this issue · 1 comments

Hello,

It could be great to have enum field as argument, to restrict values that can be passed in parameters.

Example:

@param Enum['cat', 'dog', 'horse'] $animal

Or with support of multiple types:

$order = ['asc', 'desc'];
$availability = ['first day', 'second day', 'both'];
$widthAllowed = [45, 250, 700];

So if I send the value third day for my parameter $availability, it can returns me an error.

Thanks

I cannot really parse the Enum['cat', 'dog', 'horse'] part as I'm using a third party library to parse annotations.
I'll look into supporting PHP "enum" libraries like myclabs/php-enum.