-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add functions for parsing/serializing the 't_variables' type #220
Comments
Ah so a |
Yeah, I can see why it might not be obvious. Here’s a better description of the use case. I have dozens of serverless functions written in Reason. The request handler takes a request with a JSON body, which should (in most cases) match the shape of the query/mutation variables sent from the client. In each case, I have to manually parse the JSON body, but it would be nice to have these functions generated by the ppx. I am currently using the module type to infer the appropriate input/response types in my handler function, and using the generated serializer to produce a JSON string for the response. I would like to do the same kind of thing with the input data as well. I suppose it would be ideal to have the parser function return an option/result type, but I could live with exception-raising as well. I can post a minimum-viable code snippet later when I’m at my PC of you want. |
Right now I have some compelling use cases for generating a record to represent the
t_variables
type along with functions to parse and serialize that type. The biggest thing for me is writing a server endpoint which decodes the input for a mutation. Right now I have to manually define functions to transform data likeJs.Json.t -> Raw.t_variables -> t_variables
.I see that the
Operation
module type provides the following:There is also the
makeVariables
function, but that doesn't help much because I really need to convert fromJs.Json.t
, which leaves me writing decoders for that. Ideally we would generate code for the entire round trip betweenJs.Json.t
andt_variables
. This has been done for the response typet
, so it makes sense to fill in the gap fort_variables
.The text was updated successfully, but these errors were encountered: