graphql-typed-client icon indicating copy to clipboard operation
graphql-typed-client copied to clipboard

Serialization of array of custom scalars fails

Open MrFus10n opened this issue 4 years ago • 0 comments

I created custom Time type map like this:

  Time: {
    serialize: (time: moment.Moment) => time.format("HH:mm:ss"),
    deserialize: (time: string) => moment(time, "HH:mm:ss"),
  }

When mutation accepts single Time value, it works ok. But when it accepts array ([Time!]), serialize function receives array of moment objects instead of getting them one by one.

On the screenshot below, time does not have format because time is array of moments, not moment object.

image

Mutation is called like this:

graphqlClient.chain.mutation
  .userProfileUpdate({input: {times: [
    moment("08:00", "HH:mm"),
    moment("14:00", "HH:mm"),
    moment("20:00", "HH:mm"),
  ]}})

MrFus10n avatar Dec 06 '21 12:12 MrFus10n