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

Change serialization for Int, Float and Boolean to work with objects #2382

Merged
merged 5 commits into from
Jan 23, 2020
Merged

Change serialization for Int, Float and Boolean to work with objects #2382

merged 5 commits into from
Jan 23, 2020

Conversation

alex-knyazev
Copy link
Contributor

@alex-knyazev alex-knyazev commented Jan 22, 2020

It is good to have opportunity to pass objects which have valueOf() method in resolvers of Int and Float types.

For example, I have such objects as "Money", "Price" and so on in my app, and they have valueOf() method which return value. Now I need to call valueOf() method in every resolver of such field or write custom scalar or directive.

I think changes I did are implied in native type behavior of Int, Float and Boolean fields.

… to have opportunity to pass objects which have valueOf() method in resolvers of Int and Float types.For example, I have such objects as "Money", "Price" and so on in my app, and they have valueOf() method which return value. Now I need to call valueof method in every resolver of such field or write custom scalar or directive.I think changes I did are implied in native type behavior of Int and Float fields.
!Array.isArray(outputValue)
) {
num = Number(outputValue.valueOf());
}
Copy link
Member

@IvanGoncharov IvanGoncharov Jan 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use serializeObject instead and add it in Int, Float and Boolean.
Also please update tests in https://github.com/graphql/graphql-js/blob/master/src/type/__tests__/serialization-test.js

So basically, please replicate how this is done for ID and String.

Copy link
Contributor Author

@alex-knyazev alex-knyazev Jan 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IvanGoncharov I did it.
Is it good idea to squash my 4 commits to one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it good idea to squash my 4 commits to one?

@alex-knyazev Both work, since it's small commit I can just "squash and merge" in GitHub UI.
Please don't forget to make the same changes and tests for GraphQLBoolean type.

Copy link
Contributor Author

@alex-knyazev alex-knyazev Jan 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IvanGoncharov I've added the same logic for boolean type

@alex-knyazev alex-knyazev requested a review from leebyron January 22, 2020 18:27
@alex-knyazev alex-knyazev changed the title Change serialization for int and float to work with objects Change serialization for int, float and boolean to work with objects Jan 23, 2020
@IvanGoncharov IvanGoncharov added the PR: feature 🚀 requires increase of "minor" version number label Jan 23, 2020
@IvanGoncharov IvanGoncharov changed the title Change serialization for int, float and boolean to work with objects Change serialization for Int, Float and Boolean to work with objects Jan 23, 2020
@IvanGoncharov IvanGoncharov merged commit f31f505 into graphql:master Jan 23, 2020
@IvanGoncharov
Copy link
Member

@alex-knyazev Merged 🎉
I plan to release 15.0.0-rc.2 in the next few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: feature 🚀 requires increase of "minor" version number
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants