-
Notifications
You must be signed in to change notification settings - Fork 140
Added NegativeInt and NegativeFloat scalars #6
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
Conversation
cfnelson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments here that I think might be important to address before merging. Otherwise looks good 👍
src/NegativeFloat.js
Outdated
| } | ||
|
|
||
| export default new GraphQLScalarType({ | ||
| name: 'PositiveFloat', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this name was meant to be NegativeFloat ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
src/NegativeInt.js
Outdated
| } | ||
|
|
||
| export default new GraphQLScalarType({ | ||
| name: 'PositiveInt', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe name is meant to be NegativeInt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
src/NegativeFloat.js
Outdated
| import { Kind } from 'graphql/language'; | ||
|
|
||
| function processValue(value) { | ||
| if (isNaN(value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if this check is for detecting if the value passed is only a valid number or testing for NaN. Making an assumption based on the error message, maybe Number.isFinite(value) would be better suited to validate that the value is not a Number. Assuming that you wish to disallow NaN & Infinity.
Would recommend the changes for the other Number scalar types if the above assumption is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check isFinite. I may also want to use Number.isNaN(). Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some other things I can do to maybe make this more robust like checking against Number.MAX_SAFE_INTEGER, etc. for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cfnelson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍 Will be curious to see how this pkg progresses.
| }, | ||
| "dependencies": { | ||
| "peerDependencies": { | ||
| "graphql": "^0.10.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ccuilla You will want to also add graphql as a devDependency in addition to having it as a peerDependency to allow for a simple quick install if someone clones your repo directly and wishes to run tests etc.
…r-scalars Added NegativeInt and NegativeFloat scalars
Add a couple of simple scalars that were missed in the first version.