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

Coercing variables #115

Closed
freiksenet opened this issue Aug 11, 2015 · 3 comments
Closed

Coercing variables #115

freiksenet opened this issue Aug 11, 2015 · 3 comments

Comments

@freiksenet
Copy link
Contributor

Currently Scalar types have two methods coerce and coerceLiteral. coerceLiteral is used to create a javascript value from ast, coerce is used both on variables and on data received from resolve in executors.

Unfortunately that is not enough - variables usually come from some format like json which wouldn't always support all the new scalar types and most likely will return them as string. On the other hand, eg, databases might return types in javascript format already. Therefore coerce can't support both variable coercion and execution coercion.

@leebyron suggested that for variable coercion, a new method is added to the Scalars - coerceVariable.

@freiksenet freiksenet changed the title Parsing variables Coercing variables Aug 11, 2015
@freiksenet
Copy link
Contributor Author

Okay, so we cleared it with @leebyron. coerce is actually a function that should do serialization. We've agreed to rename coerce to serialize, rename coerceLiteral to parseLiteral and add parseVariable.

I'll try to make a PR asap.

@leebyron
Copy link
Contributor

Merged in! this will be in the next release.

@dashed
Copy link

dashed commented Oct 11, 2015

These changes should reflect onto the docs: http://graphql.org/docs/api-reference-type-system/#graphqlscalartype

When playing with graphql-js, I got super confused on why coerce stuff was missing and not working.

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