Fork me on GitHub

In om-next, is a mutate function supossed to be able to return {:value nil}?


@mjhamrick afaik, the :value key only helps you document what keys are involved with the mutation, but doesn’t actually do anything.


Hey guys, what are the first things to look into when my data is not normalized coming from remote? I made sure that state is not in an atom, and ident is implemented.. A bit baffled as to why one subquery is normalized but not the other, even though they’re quite similar.


… The only difference I think could be made by the fact that it’s a parametrized query


is there a larger demo than on datascript <-> ?


@alex-glv Normalization works because the get-query function puts metadata on the query indicating which component it goes with. If you use a query that isn't properly annotated with metadata then normalization will break. So, I'd guess you're doing something funky with your parameterization? Perhaps putting in a bit of subquery as raw data instead of pulling it from the query of a component with an ident?


@qqq only datascript<->om example I'm aware of


@sineer I have been looking for that 🙂 Thanks for sharing!


@tony.kay: thanks for the tip; I am not touching query metadata, but am passing params later in the parsing stage. I'll check if there's anything that can affect it. Also, I am using query-root in ast to set remote query root, but I can't see why it'd make any difference.


@tony.kay I implemented homebrew router, and my root query was something like {:root/data [{:route1 (om/get-query route1class) :route2 (om/get-query route2class)}]} Then later in the parsing I did: (get query current-route) So normalization worked for the route1, but nor route2, even though after parsing the query there left only one join query. I replaced the root query to be joins for all routes: {:root/data [{:route1 (om/get-query route1class)} {:route2 …}} and then filter out only active route join query. And that fixed it. So, normalization works based off what your query is in the component, not what you return after parsing.


@alex-glv: that's a rather premature conclusion to make


The first query you pasted is incorrect


A join should only have 1 key/value pair; yours has 2


Yeah absolutely, the root query was incorrect, that was the cause of the issue. My conclusion was that even if you parse the query in (defmethod read :root/data) return ast for it that contains valid join (that is, all key/value pairs that are not related to the current route gone) the normalization breaks.


In other words, queries on components should be correct and not incorrect… :face_with_rolling_eyes: