fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
thosmos 2021-06-01T04:24:46.080200Z

I’m using RAD (which is RAD!) and am attempting to add a reverse many-to-many reference to a report list. In other words, the report is listing station and each station can be referenced from multiple project records (:ref :many). On each station row, I’d like to have a set of project tags, and the ability to filter the report by project. I’m not sure how to configure this sort of “reverse many ref” into either the RAD attributes or the report config. I have reverse refs in my pathom resolvers outputs and underlying datomic query, so I can accomplish this with a query like:

[{:stations/all [:station/uuid :station/Name {:project/_Stations [:project/uuid]}]}]
which passes this to a datomic pull and it returns the appropriate data. What I don’t get is how to incorporate this kind of query into the RAD station report. Any tips?

Jakub Holý 2021-06-01T08:11:04.081800Z

keep us posted 🙏 For displaying the values this https://gist.github.com/holyjak/207ed33c9ee7e003b9a779fa47c32d91#displaying-to-many-ref-attributes-in-a-report-column-as-a-value-or-a-sub-report can perhaps be of some use?

thosmos 2021-06-03T00:34:25.119Z

Oh interesting, thanks for the link. I did #2, but then the column header was missing from the table. So I added an attribute for the reverse link, but then I made the mistake of linking it to the database schema, and couldn’t figure out how to skip the autogeneration of the schema for that attribute. I realized I needed to remove the ao/schema attribute. Now the report is working and I’m attempting to get a to-many control in the form editor to work.

thosmos 2021-06-03T03:48:25.120900Z

I finally got it to work! I wound up needing to intercept the delta and rewrite it to change the owning side of the to-many references. https://github.com/thosmos/riverdb/blob/db4567b7eb957d9ee668525c8f48133421dd53e2/src/rad/riverdb/rad/middleware.cljc#L92

thosmos 2021-06-03T03:49:35.121200Z

I wasn’t able to get the pathom attr resolver approach working like your example, but i already had that part working anyway. However, my approach for the resolvers would not work for the stock RAD setup because I use my own attribute specs to autogenerate my resolvers.

❤️ 1
thosmos 2021-06-01T04:49:03.080800Z

Actually, I think this might be working. Any gotchas here?

(defattr Projects :project/_Stations :ref
  {ao/identities #{:station/uuid}
   ao/schema :production
   ao/target :project/uuid
   ao/cardinality :many
   ao/read-only? true})

Jakub Holý 2021-06-01T11:03:29.082900Z

[ANN] https://github.com/fulcro-community/fulcro-exercises has been made vastly clearer thanks to the awesome feedback I received from @alex-eberts Check out the latest version!

👏 3
⭐ 1
Michael Mossinsohn 2021-06-01T19:49:54.112Z

Hi, Does anybody have any tips / best practice about combining a recursive attribute with Fulcro RAD? I tried using a normal defattr: (defattr parent :person/parent :ref {ao/target :person/id ao/cardinality :one ao/identities #{:person/id}}) I combined it with a picker which points to a defsc for its query: (defsc PersobParentQuery [ ] {:query (fn [] [:person/id {:person/parent 1}]) :ident :person/id }) It does not end well. :) Any ideas?

Michael Mossinsohn 2021-06-02T08:35:03.115Z

Thank you for your reply! and for the Fulcro ecosystem! 🙂 I think I get an infinite compiler loop. Since it's mentioned in the developers guide (inside the code for "Example 12. https://book.fulcrologic.com/#RecursiveDemo1") that "calling get query on yourself would lead to infinite compiler recursion", I suspected that circular recursion is not supported. (which is why I did't start by providing lots of details). Since it should be supported, It's probably me... 🙂 I will simplify my code and figure out if I can get my code to work or fail even with a more trivial case. If I can't get it to work I'll ask again for some guidance (and provide all the relevant details). Thanks! Michael

tony.kay 2021-06-02T13:23:00.115700Z

You of course cannot call get-query (or any function) recursively without a termination condition...but where are you doing that? You used recursive query notation in your code sample

tony.kay 2021-06-02T13:25:57.115900Z

Forms won't auto-handle it, but you have to do a subform join on a ref, which means generating a subform class. You cannot use the form itself as its own subform, but you can write another class for that purpose.