Skip to content

Generate a serialize function that convert Config.t to Js.Json.t (opposite of parse function basically) #71

@dawee

Description

@dawee

When we want to write in the cache using writeQuery, writeFragment, fetchMore.updateQuery ... we need to send it in a JSON format.

It can work as is, if the query has no optional, no fragments in it. But if it does, then the parse function returns a type that includes one or more variants. Which is great, but it can't be reused as is as a JSON format.

Even if we try an unsafe cast it wouldn't work because Bucklescript will translate the variant as an array.

Dog(4) => [2534, 4].

What would solve this would be a generated serialize function that do the opposite of what parse is doing:

module MyQuery = [%graphql
  {|
     ....
  |}
];

readQuery(...) |> MyQuery.parse |> myTransform |> MyQuery.serialize |> writeQuery(...)

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