Fork me on GitHub
#fulcro
<
2020-05-25
>
murtaza5211:05:13

com.fulcrologic.fulcro.data-fetch/load!it takes a class or factory. My class has nested components, and I want to only load the top level component, how do I do that ? is there a way to just specify an eql query / ident, instead of a component ?

Chris O’Donnell11:05:37

You can create a separate component with whatever you'd like to load and pass that.

Chris O’Donnell11:05:54

Fulcro needs the component definition(s) to know how to normalize the results.

murtaza5212:05:12

@codonnell thanks, I also found load-fields! , I assume that should also do the job.

Chris O’Donnell12:05:12

Didn't know about that, but it sounds promising!

murtaza5213:05:02

Given nested components (datomic components defind through defattr :ref type)

{:person/name "a" 
 :person/cars [{:car/name "ab" 
                :car/insurance [{:insurance/name "cd"}]}] 
I am able to do such a pathom query
(parser {} [{[:person/id 1] [{:person/cars [{:car/insurance [:insurance/name]}]}]}])
However I am not able to do the following -
(parser {} [{[:person/id 1] [{:car/insurance [:insurance/name]}]}])
Shouldnt fulcro rad be able to generate a resolver for the above, or I am doing something wrong ?

cjmurphy13:05:55

You would need to create your own :person/id to :car/id resolver, if that path doesn't already exist from your RAD attributes. Does each person have a 'main' car?

murtaza5214:05:36

how do I check the resolver path taken by a particular query ?

cjmurphy16:05:09

I just put debug statements in the resolvers. But there are better ways I believe.

cjmurphy16:05:48

But of course that doesn't help with auto-generated resolvers.

murtaza5216:05:19

there is a trace also, couldnt get it to work though

cjmurphy17:05:17

Yeah setup with Pathom difficult in my experience. Maybe look at RAD code, template code..

cjmurphy17:05:28

So the person resolver the input is :person/id . As long as one of the outputs is :car/id , you should be right.

murtaza5217:05:26

hmm tried the above, problem is there are multiple :car/id, so a single :person/id will resolve to a vector of :car/id, and this doesnt work. When I write a db func to just pull up one :car/id then it works

cjmurphy17:05:30

Yeah, that's why I talked about a 'main' car originally. Have to have one only. You can hide other cars under another entity perhaps?

murtaza5217:05:34

did not understand, what you mean by hide them under another entity

cjmurphy20:05:19

Have another to-one reference entity that has all the other to-one cars, apart from the main to-one car. So :person/garage.

cjmurphy20:05:56

In fact for the main car consider having a simple person to car resolver.

murtaza5212:05:57

wrote a resolver for person->cars

roklenarcic13:05:17

I have a question about returning values from remote transactions. Let’s say I have a server-side mutation resolver that returns a list of items, but I would also like to return tempid mappings… how do I do that? The data types clash (I cannot add temp-ids key to a vector.

Chris O’Donnell14:05:21

I've always returned maps from remote transactions. Didn't even know it was possible to return a vector.

Chris O’Donnell14:05:30

Can you not return a map?

roklenarcic19:05:21

well the value I’m loading is a list, but I can wrap it into a map

👍 4
murtaza5214:05:03

in the rad-demo I see the seed data for the entities have both :db/id and an entity id ex :invoice/id, why do we need both ? Isnt just the :invoice/idenough for resolution ?

zilti14:05:34

:db/id is the id for the Datomic datum, :invoice/id is the invoice id. If anything, you could do without :invoice/id

zilti15:05:38

It is basically a slight abstraction from the database internals, since :db/id is technically an internal thing of Datomic

murtaza5215:05:00

yes but datomic assigns :db/id if it is not specified, so is there a specific reason that fulcro is specifying it ? does fulcro-rad use the :db/id when it generates the resolvers ?

zilti15:05:51

Assigning a temporary id to it allows you to add refs to specific datums without committing to the db first

zilti15:05:38

Pretty sure fulcro-rad-datomic doesn't care about the :db/id as long as you don't define it as the primary index of an entity

murtaza5215:05:33

@zilti thanks, that explains it.

👍 4
zilti15:05:47

I have a question as well now. I placed an svg into resources/public/images. Trying to access it via the browser only returns ["^ "] though... I have never seen that before with Ring. Is there something Fulcro-specific going on here?

Jakub Holý (HolyJak)20:05:39

That looks perhaps like transit-encoded empty value?

Chris O’Donnell15:05:03

That really depends on how your ring handler is set up, not anything fulcro-specific.

zilti15:05:30

I left it as-is from fulcro-rad-demo

Chris O’Donnell15:05:00

Looks like that's set up for some kind of blob storage for urls starting with image/.

zilti15:05:33

That is commented out though

zilti15:05:40

I guess it is a mime type issue

Chris O’Donnell15:05:38

That's possible. Based on your comment above it looks like you may be getting transit back.

zilti15:05:45

Ahh it is being served as "transit+json" yes

zilti15:05:10

Aghh, it is already configured to statically serve the contents of /resources/public... Seems like it doesn't do it for all file types

zilti15:05:58

Yes, png works fine. svg fails

murtaza5216:05:16

What is the purpose of com.fulcrologic.rad.attributes-options/targetwhen used for :reftypes ? I thought it was being used for generating resolvers, but that doesnt seem to be the case.

zilti17:05:05

I've just been wondering... do I get any functional advantage (or lines-of-code advantage) from using Semantic UI React components over just using plain Semantic UI?

tony.kay20:05:31

@zilti I do not use any Semantic UI React components unless they provide real logic (i.e. Dropdown). If I just want something like a grid or table, I just use the the CSS classes. It is less hassle, less overhead, etc.

Jakub Holý (HolyJak)20:05:45

Same here. I have used eg the Popup component because of its behavior.

tony.kay20:05:42

if you want a LOC advantage, make your own functions or macros…i.e. we have a divs macro that takes a sequence of class kws, and results in nested divs:

(divs :a :b :c ...) => (div :a (div :b (div :c ...)))

tony.kay20:05:39

@murtaza52 look through the source of both RAD the Datomic adapter, and RAD semantic UI. I don’t remember off the top of my head everywhere it is used, but it is important to know what kind of thing a ref points to in some situations.

murtaza5221:05:49

If I want to see the pathom path taken to resolve a given eql query, how do I do that ?

mruzekw21:05:08

Does fulcro-garden-css work with React Native?

mruzekw21:05:29

(I'm technically using react-native-web but same API as far as I'm aware)