Graphql_wrapperThis file provides a wrapper around an ocaml-graphql-server Schema module, in order to build to_json functions for query fields. These can later be used to serialize queries.
Arg.scalar function has a new ~to_json argument that is morally the inverse of coerce. The most common case where these functions are not inverse of one another is when the coerce function can fail during parsing and return a result type, but it does not make sense for the to_json function to take a result type as input.Arg.obj function has a new ~split argument, which is also morally the inverse of coerce: while the coerce function for obj arguments builds an ocaml value from the fields of the objects, the split describes how to split an ocaml value into these fields.The split argument is used as such:
let add_payment_reciept_input =
obj "AddPaymentReceiptInput"
~coerce:(fun payment added_time -> { payment; added_time })
~split:(fun f (t : t) -> f t.payment t.added_time)
~fields:[...]The to_json function from the add_payment_reciept_input can then be used as such :
let input_as_json = add_payment_reciept_input.to_json
{payment = "..."; added_time = "..."}