There is some integration from om "pull pattern" to graphql? Is possible to translate one to other? Some tutorial/docs/how to?
Are these ideas right?
1- Given an application state, I can generate a "pull pattern" with all data needed to render this state.
2- given these pull pattern, I can make a single/unique request from server and get all data back
3- Once the backend knows last client query, it can send a websocket message with a "refresh"
How do I tell transact! that I want all components that use a certain ident rerendered. In transact! call I can specify reads after mutations, so I want to specify something like [:person/by-id 2]
, but that doesn't seem to work.
@souenzzo seems accurate, but instead of "pull pattern" we usually call it "query"
@souenzzo although not documented yet, in Pathom I've written some helpers to convert from Om Graph Query to GraphQL: https://github.com/wilkerlucio/pathom/blob/master/src/com/wsscode/pathom/graphql.cljc
you can find example usages on the tests: https://github.com/wilkerlucio/pathom/blob/master/test/com/wsscode/pathom/graphql_test.cljc
@roklenarcic you should not specify the ident, but the attributes that you need refresh, it's recommended to think on the attributes, not the entities, so you get a more targeted refresh
if you really need you could use the attribute :person/id
, since all of your persons probably have it, but still, better to say the attributes you need refresh, it's usually clear what they are after a mutation
I was playing with a basic devcards setup and am seeing something I don't understand - I create a card with a component and state map. With no query specified I can fetch the component props fine, but if I specify a query the props values comes back as empty atoms. Does anyone know what is going on?
@wilkerlucio but that will refresh render of all persons, not of the single one
when I add data to entities in mutations, do I need to take care of normalization myself?
@souenzzo I had a go at this at one point:
Seemed perfectly possible but I didn't polish it.
@roklenarcic yes about normalization, you have to do it yourself on mutations
and yes about all the persons, and that's fine, remember that if you transact sending the component as the reference, that component will be automatically updated, no need for refresh
that's the most common case for ident refresh, the component itself that triggered the transaction
otherwise just go by keys, unless you find a case that gets too slow, on my experience it just works fine
@wilkerlucio The usual case is that I have a list of entities then I have a popup editing the entity. The save transaction uses the popup as it's ref, but I'd like the list item to be updated as well. Both have same ident. I guess that's one "hole" in the om.next model, I need to rerender all items in the list by specifying an attribute of the person
did you tried sending the :person/id
? the performance hit is too much?
Nah it will prob be fine
Don't have that much data. But I always like to keep lookout of optimal ways of doing things