Fork me on GitHub
#fulcro
<
2020-05-12
>
tony.kay04:05:02

RAD update: I got most of table groupings fleshed out today. So, the table support to date was purely row-based: you have fixed columns and get n rows from the server. This is great for simple CRUD, but falls way short for many reporting needs. I have two things I’m planning to implement to help solve the wider need: grouping (mostly done, need “rotate” support in UI), and derived rows (still to do, but even more general). The grouping support allows you to use the same report parameters, but return a single map with rolled up results over some groups. The demo has an example with live resolvers that roll up data from invoices. The short description is that adding ro/grouped-on causes the report to expect a single result with a vector for each column. These are then transformed into the “rows”. A rotate? option will be added soon that allows you to treat the columns as rows so you can display the values “across” instead. Source of interest in the demo: https://github.com/fulcrologic/fulcro-rad-demo/blob/develop/src/shared/com/example/ui/sales_report.cljc#L76 https://github.com/fulcrologic/fulcro-rad-demo/blob/develop/src/shared/com/example/model/invoice.cljc#L65 (through the end of file) The data returned from the resolver looks (sorta) like the comment at the bottom of that last file.

❤️ 8
tony.kay04:05:03

This support will also be great for graphical reports, since this format of the data is very often exactly what you need for charts and graphs.

tony.kay04:05:17

The “derived rows” is also a simple add: the idea is to add a stage to the report (currently it does load -> group (new) -> filter -> sort -> paginate). The derived rows feature will just add a stage to that pipeline that lets you take the raw input rows and convert them to whatever it is you want to use. I need to give it more thought, but it might turn out to be the stage I just added (group) is just a special case of this generalization.

❤️ 12
fulcro 16
🤙 8
aw_yeah 4
murtaza5208:05:21

If I am defining mutations under the same namespace for clj and cljs each ex- abc/mutations/sales.cljand abc/mutations/sales.cljs . Is this ok or will it lead to conflicts ? The reason I ask is I only see the cljc being used and never separate files with same ns for both clj and cljs.

👍 4
cjmurphy10:05:52

You should be fine with separate clj and cljs files.

murtaza5209:05:33

I want to do a pathom query where I can pass multiple params - this one works - (parser {} [{[:a/a 1] [:a/name]}]) however this one doesnt - (parser {} [{[:a/a 1, :a/b 2] [:a/name]}]) How do I pass multiple params to a pathom parser ?

cjmurphy10:05:11

You use :pathom/context to get multiple inputs: https://wilkerlucio.github.io/pathom/#_multiple_inputs

murtaza5213:05:03

(parser {} [{(account-edge {:pathom/context {:a/b 2}}) efarm/account-id->farms}]) @U0D5RN0S1 the above throws an error key should be an integer, is the format I am using correct ?

cjmurphy13:05:25

I just use it from Fulcro for loads.

murtaza5213:05:44

yup the one with backtick does not throw error anymore, however when I print the params from the resolver it still doesnt show the pathom/context vars

murtaza5213:05:14

(defresolver farms-by-account-id [env {:account/keys [id] :as p}]
  {::pc/output [{:farms [:farm/name :farm/id :farm/address :farm/account]}]
   ::pc/input #{:account/id}}
  (prn p)
  {:farms (dfarm/get-farms-by-account-id id)})

murtaza5213:05:52

it only prints the id, and not the :a/b key I called it with

cjmurphy13:05:38

There will be a plugin that deals with the :pathom/context part.

cjmurphy13:05:32

And it is not params, it is inputs. inputs for resolvers.

cjmurphy13:05:55

Seems like it is the ident-reader that handles :pathom/context .

murtaza5214:05:31

I am creating a parser using com.fulcrologic.rad.pathom/new-parser, and the it includes the open-ident-reader by default. So I guess I don have to do anything and the :pathom/context params should get added automatically to my params ?

cjmurphy14:05:52

They should be added automatically to your input, not your params. In a defresolver the arg after env is input.

murtaza5218:05:28

Sorry I meant inputs only, I have placed a prn in the input, see my defresolver above. It only prints the ident and not the other pathom/context map.

cjmurphy18:05:34

Your input is only :account/id . The second input, that you put in :pathom/context , should also be specified. i.e. the ::pc/input set should contain 2 keywords.

murtaza5214:05:15

thanks @U0D5RN0S1 that did the trick, I assumed that the input is only for the resolvers to determine if it can satisfy a given query or not. I thought that everything will get passed in the args irrispectively.

Tuomas11:05:29

I’m getting longs in the client db (datomic :db/id)

#object[Long 21836300927631454]
I’m guessing it’s needed for transit? So this should be handled in the client? Any smart ways to handle this in the client? It’s a bit weird though, since the type is long for all :db/ids
{:db/id 34353141298233449} java.lang.Long
{:db/id 3602000092594272} java.lang.Long
But in the pathom response I’m getting
"~i34353141298233449"
3602000092594272

tony.kay15:05:09

js Number cannot hold bigger longs, so transit converts them to goog Long (only when they would overflow), which works perfectly fine with Fulcro. There is no better solution that I can think of objectively…you could use strings, but that certainly seems subjectively and objectively worse to me.

Tuomas16:05:35

Ah that makes sense, thanks. Yeah I agree with you. The problem I had was that I kept getting nil for id

:ident         :thenamespace/id
:query         [:thenamespace/id]
I checked the DB and there was one blue id (number) and others were black (goog Long). Everything worked as expected with the number, so I thought the problem was goog Long. It’s most likely something else I’m doing wrong

Tuomas16:05:18

Yeah it’s because of routing and my :will-enter. pushy sets token to entity/id and in :will-enter I used to just parseInt it (autoincrement id). It’s all clear now thanks

tony.kay19:05:28

cool, yeah routing using strings means if you use real db ids you have to be careful

Eugen19:05:10

hi, can I use fulcro with an servlet container like tomcat ? the use case is to integrate with existing application that runs inside a template container. I've searched the docs a bit and the issues and I could not find something related to this.

tony.kay19:05:47

Fulcro’s libraries are mostly front-end (we specify how server interactions take place, but not the implementation of them on the server), and the back-end is a small bit of Ring middleware mostly using Pathom. Backend can be whatever, including a servlet adapted to Ring

Eugen19:05:06

thanks. I just saw that ring has servlet integration so I'll look into that

tony.kay19:05:08

It just needs to expose a single POST endpoint that can service transit+json

Eugen19:05:38

similar to graphql, awesome. I'm planning to do a POC API for Apache OFBiz ERP with fulcro

tony.kay20:05:22

cool. good luck 🙂 Yeah, you don’t even need to use Ring…the handle-api-request function in Fulcro’s middleware does a little bit of response rewriting…but other than that it is just an endpoint that supports that encoding.