-
Notifications
You must be signed in to change notification settings - Fork 0
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
Can Post operation parse the whole attributes? #5
Comments
Thanks for explaining your use-case and giving code examples. There are several things I notice. First, to your specific question: I interpret your use-case to mean that you want to parse the
In both of the above cases, I you must use Second, since there are no GET operations for commands (and assuming the command is created as-is from the request), it may be better to return Third, it seems that you use the |
Hello, FirstI don't need to parse the whole Just to clarify it more, the Command type itself is a more complex than I showed in the example above, it has a different item types and even a nested objects in it. I have a So the first option Second
ThirdThe example above was simplified, not to be confusing with other parts. In the real app, there will be something like this .AfterCreateAsyncRes(fun ctx command -> command |> ctx.HandleCommand) Where And the |
It seems you understood me to mean that you can parse the whole top-level let data = define.Attribute.SimpleUnsafe(...) // etc., deserialize to `JsonElement` or similar You put all the really dynamic stuff in this If you want to do that for the whole If your model really is that dynamic, then I think that perhaps JSON:API isn't the right solution for your use-case. JSON:API is focused on structurally well-defined resources and semantically well-defined operations on these resources. Don't hesitate to let me know if anything is unclear. |
Oh I see. Yes I was aware of that option from the beginning. If the input data could be {
"data": {
"type": "commands",
"attributes": {
"command": { ...commandJson... }
}
}
} It would be easy and I could use just a But the format is unfortunately this: {
"data": {
"type": "commands",
"attributes": { ...commandJson... }
}
} So the That is why I'd like to parse the whole And the So if the It seems a bit complex, but in the end, it might be a simpler than "share" the Command schema parsing out of a Well thank you for your time! |
You know your code base best, and how complex each solution is. But do consider that maybe Felicity isn't the right tool for this particular job. Perhaps another JSON:API framework, or no JSON:API framework at all for that matter (just parsing the body manually), may be simpler. |
Hello,
I'd like to ask, if there is a way to parse whole attributes "json" as once or must I create every single attribute?
I'm doing a simple "command handler" api, which only receives generic commands and will do stuff based on that specific command (so yes I know, its more like GRPC, but we are using json-api format for that as well).
There won't be any Get, Put or Delete requests allowed for this resource, only Post would be available, to send new commands.
So I have a command
Note: It is a bit simplified, but otherwise pretty much like that.
The request the api gets could looks like this:
I already have the library to handle commands, to parse/serialize them from/to string (json) and I'd like to reuse that in json api, but I can only parse a single attribute at a time AFAIK.
So is there a way to just parse the whole attribute object as is?
Thanks!
The text was updated successfully, but these errors were encountered: