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

Rework argument & query serialization #49

Merged
merged 10 commits into from
Jun 14, 2020
Merged

Conversation

obmarg
Copy link
Owner

@obmarg obmarg commented Jun 14, 2020

Prior to this change we serialized arguments when building up the
selection set, and stored the results of that serialization in the
Argument struct. This worked, but led to an awkward API where you build
the selection set, convert it to a QueryBody which could fail, and
then convert it to JSON which could also fail.

This updates the Argument struct to store a Box<SerializableArgument>
instead. This simplifies things: we can now serialize the Query
directly, and the Argument serialization will happen there, leading to a
single point of failure rather than multiple.

Also updated the serialize & encode functions to return Box<Error>
rather than ().

Fixes #42
Fixes #45

Prior to this change we serialized arguments when building up the
selection set, and stored the results of that serialization in the
Argument struct.  This worked, but led to an awkward API where you build
the selection set, convert it to a QueryBody which could fail, and
_then_ convert it to JSON which could also fail.

This updates the Argument struct to store a `Box<SerializableArgument>`
instead.  This simplifies things: we can now serialize the Query
directly, and the Argument serialization will happen there, leading to a
single point of failure rather than multiple.
Rather than `()` which was a bit useless.

Fixes #42
@obmarg obmarg changed the title Rework serialization Rework argument & query serialization Jun 14, 2020
@obmarg obmarg merged commit 27af6d9 into master Jun 14, 2020
@obmarg obmarg deleted the serialize-error-rework branch June 14, 2020 15:06
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

Successfully merging this pull request may close these issues.

Remove unwraps Query::body returns () for errors
1 participant