Skip to content

isNullish() doesn't cover types well enough #208

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

Closed
threadwaste opened this issue Jun 14, 2017 · 3 comments
Closed

isNullish() doesn't cover types well enough #208

threadwaste opened this issue Jun 14, 2017 · 3 comments

Comments

@threadwaste
Copy link
Contributor

threadwaste commented Jun 14, 2017

Disclaimer: This might be me simply misunderstanding the intent of isNullish. I'm still deep diving the values implementation.

Currently, isNullish attempts to determine whether a value is a zero-value (in the case of values), or nil (in the case of pointers). This mostly works in its current form, but misses several cases. For example, *time.Time per this playground.

While digging into this, I came to a very sloppy implementation [while hacking this problem out] that involves reflect. To me, this makes more sense. However, despite substantial use of the empty interface, this library often times in cases like this forgoes reflect in favor of type assertions. Is there a technical reason for that? Or, simply an approach that worked initially, but hasn't evolved as the library grew?

At any rate, please let me know if I'm misunderstanding the intent of isNullish. Similarly, if moving this implementation over to one based on reflect is okay for the community, I'm happy to tidy up what I have here and open a pull request.

@threadwaste
Copy link
Contributor Author

threadwaste commented Jun 14, 2017

Okay, and now of course after spending a decent amount of time here, I'm realizing after taking a breather that this is just a scalar implementation issue. The type assertions over empty interface are valid because the GraphQL types are of limited scope, making it clean. What I'm missing here is a time scalar that converts this to one of the relevant GraphQL types.

Oof. 🤕

@bbuck
Copy link
Collaborator

bbuck commented Jun 14, 2017

No worries on that, there is at least one highly known issue with isNullish and that is that "" is considered null when (according to the issue/PR`) is definitely not the desired value.

@chris-ramon
Copy link
Member

thanks for closing this one, landed to master via: #220

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

No branches or pull requests

3 participants