Skip to content

Decoding fails for non-string scalars #37

Closed
@xtian

Description

@xtian

In our application we have scalars such as Watts and WattHours where the back-end serializes the value to a JSON float. However, the Fields that Graphqelm generates expect all scalars to be serialized as strings:

power : Field (Maybe Api.Scalar.Watts) Api.Object.SomeRecord
power =
    Object.fieldDecoder "power" [] (Decode.string |> Decode.map Api.Scalar.Watts |> Decode.maybe)

This decoder causes the whole decode for this record to fail and return a Nothing

This is also problematic on the encoding side since the back-end will expect these values to be serialized as JSON floats there as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions