You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was thinking about how we could allow any custom type in params without needing to support everything. The best way is just provide an escape hatch so when you need something super custom, you have access to it.
For params, maybe you're doing a JSON API (or in my case, graphql), and you want to pass in a custom type
classGraph::Comments::Create < GraphAction
param comment_input : Graph::Inputs::CommentInput
post "/graph/comments/create_comment"do#....endend
In this case, it's going to be some sort of nested JSON object. We could maybe use an annotation here to let you specify your own parser. Crystal's JSON::Serializable actually has a similar option where you can pass converter like the EpochConverter.
So I'm thinking maybe it looks something like
classGraph::Comments::Create < GraphAction# note: can't be Lucky::Param
@[Lucky::Param(converter:Graph::Inputs::CommentInput)]
param comment_input : Graph::Inputs::CommentInput
post "/graph/comments/create_comment"do#....endendclassGraph::Inputs::CommentInputincludeJSON::Serializableproperty text : Stringproperty author_id : Int64# no clue how this would work, but maybe this is ok?defself.from_params(value : String)
self.from_json(value)
endend
I'm sure there's a lot of weird edge cases around this, but I wanted to at least get this written down.
The text was updated successfully, but these errors were encountered:
I was thinking about how we could allow any custom type in params without needing to support everything. The best way is just provide an escape hatch so when you need something super custom, you have access to it.
For params, maybe you're doing a JSON API (or in my case, graphql), and you want to pass in a custom type
In this case, it's going to be some sort of nested JSON object. We could maybe use an annotation here to let you specify your own parser. Crystal's
JSON::Serializable
actually has a similar option where you can passconverter
like the EpochConverter.So I'm thinking maybe it looks something like
I'm sure there's a lot of weird edge cases around this, but I wanted to at least get this written down.
The text was updated successfully, but these errors were encountered: