Fork me on GitHub
#fulcro
<
2018-03-03
>
myguidingstar10:03:31

@tony.kay @wilkerlucio walkable has been updated with ability to batch queries (aka solving N+1 problem)

myguidingstar10:03:27

I'm working on some minor issues before releasing to clojars

nha13:03:14

Hello 🙂 I need a bit of advice about how to name/structure a query: I have a user that will have api keys (typical SaaS thing - think about https://github.com/settings/applications (the oauth tab)). I want to make a component that will list the api keys of the user (only the ids, not the actual value). Something a bit like Github does with SSH keys / OAuth tab ( https://github.com/settings/applications ) and the same component (I guess) will provide a mutation to create a new key (?). How should this look like? [:customer/api-key-ids] ?

(defui Security
  static om/IQuery
  (query [this]
         ;; get a list back like that? Or is the naming for lists different?
         [:customer/api-key-ids])
  Object
  (render [this]
          (let [props (om/process-roots this)]
            (html
              [:div.ui.list
               (for [api-key (:customer/api-key-ids props)]
                  ;; something like that
                  [:div.item api-key])]))))

wilkerlucio14:03:34

@U0ALP2929 think about entities, the api key seems like an entity on your system, so I think would make sense to descende a query level for it, eg: [{:customer/api-keys [:api-key/id]}]. This will align things better for you when using fulcro, because now the component that renders the api key can have an ident, this is also better for extension, if you want to show more information about it (like when it was created), just add to the api key component query. makes sense?

nha19:03:58

Does that work also when I don't yet know the id ?

wilkerlucio20:03:21

@U0ALP2929 yes, if you are creating new entries you should use (prim/tempid) to generate a temporary id for it

nha21:03:35

Thanks I’ll try that 😄

magra14:03:12

The umlaute thing: I have it working. If the json gets generated by fulcro.server/wrap-transit-params it gets send as utf8. But wrap-transit-params checks whether there already exists a Content-Type header. If the json gets generated by fulcro.server/handle-api-request it gets send as ISO-8859 on my luminus ummutant setup, wrap-transit will not touch the header as it already has a Content-Type header. My first hack ist to get wrap-transit-params to handle the response anyway. handle-api-request sets the Content-Type to "application/transit+json". wrap-transit-params sets the Content-Type to "application/transit+%s; charset=utf-8". I still do not know why the server defaults to ISO-8859. Thanks for the help and pointers and your patience with a rookie.

Adam Bubeníček14:03:27

Is it possible/safe to use fulcro.server in cljs/node environment? I couldn’t find any information on this, and I still don’t know Fulcro enough to write my own server to test it out. I assumed it wouldn’t work (since it’s in clj and not cljc), but importing the ns appears to work fine. The use case I have in mind is resolving remote queries from AWS Lambda, where Java environment’s warm up time and memory consumption appear to be significantly worse than those of node.js. I hope that makes sense, thanks for any info!

wilkerlucio15:03:33

@adambubenicek not the fulcro.server directly, but you can use express or something and hook some endpoint to a parser, it's pretty strait forward, the main pain point might be just setting up the transit handlers, but reading a bit code I guess you can figure out

wilkerlucio15:03:22

@adambubenicek I have wrote this in past, still uses Untangled (old name for Fulcro), but I think you can get useful snippets from it https://github.com/daveconservatoire/dcsite-cljs/tree/master/src/server/daveconservatoire/server

wilkerlucio15:03:44

it uses a nodejs server to expose a fulcro api

Adam Bubeníček15:03:54

Oh sweet. I expected it would require more manual plumbing, but I'm glad at least the parser will work. And I'll definitely check the repo. Thank you so much @wilkerlucio, this is very helpful

wilkerlucio15:03:38

@adambubenicek actually, probably the harderst part is writing the async parser, since everything on node is async, you have to deal with that by hand... feel free to steal the implementations there, the pathom library that I wrote has some support for it (undocumented, and still in progress, but depending on your needs it might work, work for daveconservatoire)