Fork me on GitHub
#fulcro
<
2018-07-17
>
tony.kay00:07:34

@montanonic there is also initLocalState which goes into component-local state (React) if that’s what you’re looking for.

montanonic00:07:51

Haha, I was just literally looking at that now

tony.kay00:07:57

The function you give there can be used identically to a react class constructor, other than what you return becomes the local state

👍 4
tony.kay00:07:18

but it is called once and only once during component construction, so anything else you’d normally do in a React class constructor can go there

montanonic00:07:34

Which means I can trigger mutations on the root from there, supposedly, too

tony.kay00:07:41

just realize that that is different that state based on component query

tony.kay00:07:56

so, mutations have to do with database state, NOT component local state

montanonic00:07:06

Yes, definitely, it hadn't been clear to me earlier

tony.kay00:07:10

they are different things…one is managed by React ON the component instance, the other is database of Fulcro

👍 4
tony.kay00:07:11

If you want to trigger “ensure this is such-and-such” for the state database of the app, then you can run a mutation via componentDidMount

montanonic00:07:58

One other question on this: how can I fetch the local state

tony.kay00:07:06

prim/get-state

tony.kay00:07:12

you mean react state, right?

tony.kay00:07:31

(prim/get-state this)…see docstring for more info

montanonic00:07:00

looking at it now; okay, totally makes sense, I was confusing myself with get-initial-state, which is entirely different

tony.kay00:07:28

sure…might be a good idea to watch some of the YouTube videos…I try to be very concise in them, and a lot of people find them useful when getting started

tony.kay00:07:39

watch them at 2x if they seem slow 🙂

montanonic00:07:44

I have! They are excellent, could probably use a revisit though since internalizing these things takes a bit of time.

myguidingstar13:07:10

@wilkerlucio is it possible to have autocomplete keywords in OgE without using pathom connect?

wilkerlucio13:07:43

the auto-complete feature depends directly from the connect indexes to work

wilkerlucio13:07:30

@myguidingstar I would love to see walkable with a connect integrated version, for those cases where we have some external source of schema (like SQL, or GraphQL) you can do a more advanced integration where you generate the indexes instead of hand writing it, I would be glad to help you get there if you like to go on this direction, there is some work done for GraphQL, the idea is very similar

myguidingstar14:07:57

@wilkerlucio thanks a lot. I'm interested in such integration, too and I've read pathom connect doc recently

myguidingstar14:07:29

however walkable took a bit different approach, I'm still thinking of a way to make it work the pathom connect way

myguidingstar14:07:23

I should do some experiments first. I'll let you know then

wilkerlucio14:07:37

@myguidingstar it shouldn't change much about walkable code, the extra work for connect is more about instructing the engine when the walkable resolver should be called (which attributes it should respond to), from there you can trigger the resolver and use parent-query for defining the query to run

myguidingstar15:07:09

I'm looking at the function p.connect.graphql/build-query's unit test

myguidingstar15:07:30

what's it input and output?

wilkerlucio16:07:13

input is environment and entity, output is the query that is going to be sent to GraphQL

myguidingstar16:07:17

more details about the output please?

wilkerlucio17:07:42

its a subquery, pathom will be processing a single attribute, this looks in the parent and build a query to leverage sibling elements that can be fetched on the same request

wilkerlucio17:07:53

by query I mean a regular query, like [:foo :bar]

myguidingstar17:07:34

from the source code, that function seems to miss placeholders?

wilkerlucio17:07:12

yeah, placeholders still not supported there, but I got recently a case where I might need to support then, so I should work on that soon

myguidingstar17:07:08

regarding walkable - connect integration, should everything have a place in indexes?

myguidingstar17:07:40

say I have the query ::top-products (or [{::top-products [:product/id :product/name :product/price]}]) that return the result from sql query select id, name, price from "product"

myguidingstar17:07:08

what should the ::pc/input and ::pc/output of its resolver in the index be?

wilkerlucio17:07:22

the way to go is defining a prefix for your integration, so when you generate the index you prefix the things with that

wilkerlucio17:07:42

so for example, if you call you db my-app, you can use the my-app prefix

wilkerlucio17:07:53

so for the table product, it would be :my-app.product/id :my-app.project/name ...

wilkerlucio17:07:30

this allows for many implemenations live together, and on the index you point those to your resolver

myguidingstar18:07:10

@wilkerlucio what about ::pc/input and ::pc/output?

wilkerlucio18:07:53

those are helpers to define a la cart, you don't need it on the custom implemetantion

wilkerlucio18:07:19

they are only used when you add something new to the index, but since you are going to generate the index separated, this doesn't matter, you can just don't provide those on the resolver data

myguidingstar18:07:04

does those ::pc/input and output help with caching?

myguidingstar18:07:55

also, what exactly is cached in connect?

wilkerlucio18:07:40

usually we cache by resolver/input, but on those adv integrations that will not work, so you must disable cache for your resolver (set ::pc/cache? false on the resovler)

wilkerlucio18:07:56

by default it caches during the request, if you ask the same resolver with the same input, it will be cached

wilkerlucio18:07:17

but in this dynamic scenario your result is also based on the subquery/env, so the caching would not work for that

wilkerlucio18:07:34

what is in ::pc/input and ::pc/output don't matter in the end, they are helpers to construct the index, what matters is what will be in ::pc/index-oir (for parsing) and ::pc/index-io (for auto-complete)

wilkerlucio14:07:11

I suggest checking this query builder for graphql, walkable can use something similar: https://github.com/wilkerlucio/pathom/blob/http-drivers/src/com/wsscode/pathom/connect/graphql.cljc#L280-L290