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

Scalar array-types are not handled properly #12

Open
slzhengwc opened this issue Aug 27, 2021 · 0 comments
Open

Scalar array-types are not handled properly #12

slzhengwc opened this issue Aug 27, 2021 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@slzhengwc
Copy link

This may be a result of #3.

Our case is like the following.

scalar Interval

type ThingWithInterval {
  interval: Interval
}

Interval is mapped to a corresponding type, like so:

type Interval {
  start: number;
  end: number;
}

From server to client (using Apollo), we serialize the Interval like so:

serialize(value: Interval) {
    return [value.start, value.end];
},

Then we deserialize the serialized-Interval using this custom scalars exchange like so:

Interval(v) {
   console.log("Interval input: ", v);
   return new Interval(v[0], v[1]);
}

The code runs the deserializer twice: once for each number in the serialized array-version of Interval.

For example, let us say the serialized Interval the client got was [100, 200]. Then the output from the console.log in the deserializer would be:

Interval input: 100
Interval input: 200

Instead, we would expect the deserializer should run on the entire array. Then, the output from the console.log would be:

Interval input: [100,200]
@clentfort clentfort added bug Something isn't working help wanted Extra attention is needed labels Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants