Skip to content

Improve data marshaling between Perl and GraphQL #17

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

Open
stevan opened this issue Sep 16, 2018 · 0 comments
Open

Improve data marshaling between Perl and GraphQL #17

stevan opened this issue Sep 16, 2018 · 0 comments
Labels
needs improvement Something that needs some improvement question Further information/thought is requested/required
Milestone

Comments

@stevan
Copy link
Owner

stevan commented Sep 16, 2018

We need to be able to marshal our input data from Perl. Currently we handle simple scalar type literals for input (ex: query { setName(10, "Alice") }), but we cannot handle complex types like lists, object literals or Schema::InputObject types (ex: query { setAttr({ "id" : 10, "name" : "Bob" }) }).

AST nodes

We need to improve the type checking of Literal values in AST nodes, this is covered with issue #15.

The AST nodes for the complex types are actually already defined, we just do not handle the conversion of these types into Perl values.

Graph::QL::AST::Node::ListValue
    values => [ Graph::QL::AST::Node::Role::Value ]

Graph::QL::AST::Node::ObjectValue
    fields => [ 
        Graph::QL::AST::Node::ObjectField {
             name  => Graph::QL::AST::Node::Name
             value => Graph::QL::AST::Node::Role::Value
        }
    ]

AST to Perl Literal conversion

Our existsing conversions between AST nodes and Perl literals is pretty sloppy, you can see this if you look at the comments in the Graph::QL::Util::AST package.

Here is the Input Values section of the spec, which basically tells us exactly what we need to do.

Validation & Internal representations

Here is the spec from the Schema point of view, which include information like parsing input, coercions, etc.

Tests

An example test case for more complex input to arguments is currently commented out, but can be added.

See Also

This code can also be referred to for "inspiration":

Related Issues

This is related to the Schema::InputObject work in #28 in that it is about parsing argument input data, but InputObjects are just an extra layer, so not critical (hence the separate ticket).

@stevan stevan added question Further information/thought is requested/required needs improvement Something that needs some improvement labels Sep 16, 2018
@stevan stevan added this to the v0.01 milestone Oct 10, 2018
@stevan stevan changed the title Improve the AST <-> Literal conversions Improve how we handle our input sources Oct 10, 2018
@stevan stevan changed the title Improve how we handle our input sources Improve data marshaling between Perl and GraphQL Oct 10, 2018
stevan added a commit that referenced this issue Nov 20, 2018
[issue #17]Added support for ListValue and ObjectValue while converting GraphQL …
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs improvement Something that needs some improvement question Further information/thought is requested/required
Projects
None yet
Development

No branches or pull requests

1 participant