Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"empty" values in dropdown fields #129

Closed
timkelty opened this issue Aug 13, 2018 · 3 comments
Closed

"empty" values in dropdown fields #129

timkelty opened this issue Aug 13, 2018 · 3 comments

Comments

@timkelty
Copy link
Contributor

I think you're "faking" this because enums can't be empty…

static function graphQLEnumValueForString($string): string {
$string = preg_replace('/[^a-z0-9_]+/i', ' ', $string);
$string = preg_replace_callback('/\s+(.)/', function ($match) {
return ucfirst($match[1]);
}, $string);
if ($string === '') {
$string = 'empty';
}
return $string;
}

Can't they be null? Seems like that might be a better choice.

@markhuot
Copy link
Owner

markhuot commented Sep 7, 2018

Unfortunately an enum value's name can not be null… GraphQL, essentially, tracks enums like this,

$enum = [
  'name' => 'value',
  'fall' => 'fall',
  'SPRING' => 'spring',
  'All Year' => ''
]

The name from above is what you type in to a GraphQL query, such as,

{
  entry(enumField: name) {
    #...
  }
}

From the GraphQL spec the name must be a string. So, in the current configuration we end up with,

{
  addSport(season: empty) {
    #...
  }
}

In the above think of empty not as a string, "empty", but as a keyword for empty, if that makes sense.

--

Note: there was actually a bug here with how empty values were handled on upsets that is fixed on dev-master now.

@markhuot
Copy link
Owner

markhuot commented Sep 7, 2018

I'm going to leave this open until a stable tag is created.

@markhuot
Copy link
Owner

Closing this issue. The fix is included in version 1.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants