Fork me on GitHub
#pathom
<
2020-04-04
>
russell01:04:16

Is it not possible to do the "fulcro client queries graphql remote directly" trick made famous by https://github.com/codonnell/crudless-todomvc with fulcro 3? It seems like pathom requires e.g. fulcro.client.network which does not seem to exist?

russell01:04:19

Do I probably want a separate pathom parser server anyway?

Chris O’Donnell01:04:23

It's very possible to do it with fulcro 3.

Chris O’Donnell01:04:36

The code that implements the fulcro remote is pretty small; you can implement it yourself. I think someone posted a gist here recently showing how to do it.

Chris O’Donnell01:04:13

I do personally prefer using pathom in the server now, but there are pros and cons to both approaches.

russell01:04:45

Is this exactly what is meant by the simple/advanced dichotomy at https://wilkerlucio.github.io/pathom/v2/pathom/2.2.0/graphql/fulcro.html#Connect ?

Chris O’Donnell01:04:55

No, those are both talking about using pathom in the client.

Chris O’Donnell01:04:58

I am writing a blog series showing how to set up an application with fulcro in the client and pathom in the server at https://chrisodonnell.dev. Another example of that setup is the fulcro template (https://github.com/fulcrologic/fulcro-template).

russell01:04:02

Do you think that Hasura provides any added value when you are already running pathom on the server? Simply writing the resolvers' SQL directly seems to work well in the mygiftilst example, is there a point whre you think it becomes unwieldy?

Chris O’Donnell01:04:47

Hasura is an efficient and feature-rich graph query parser, and it just works without you having to write any code, which is awesome. However, when you use Hasura your query schema is forced to mirror your database table structure. In practice I've found that coupling to be pretty constraining, and so I've preferred to write the resolvers myself.

Chris O’Donnell01:04:08

Another nice advantage of hasura is its out-of-the-box support for subscriptions.

russell01:04:23

Yes I was primarily enticed by the possibility for it to work with ~0 glue and i was prepared to tolerate potential issues like mutations being weird

russell01:04:19

If the zero-code dream can't be realized then it does seem better to just write resolvers to SQL myself

Chris O’Donnell01:04:24

It should be possible to set up hasura without much glue

souenzzo01:04:03

I'm working on a pathonized hasura 😉

Chris O’Donnell01:04:43

Neat. 🙂 Is it open source?

souenzzo18:04:24

Nothing public ATM In our current project, we are generating resolvers from others specs like #datomic (schema), hodur, #clojure-spec. It's still binded in many other system components. But once I release the main product, I will work to split out this.

souenzzo18:04:21

(swagger, SQL, GQL and other EQL API's will eventually be demand by the project)

Chris O’Donnell18:04:32

Cool, I look forward to it 👍

Chris O’Donnell18:04:42

How are you managing authorization rules?

souenzzo18:04:07

It's still a good question. We are B2B and we kind of "don't care" to much ATM. There is 2 implemented methods: 1- "cleanup query", that given user creds, we remove some attributes/reject the query 2- There is also many instances of "parser", some parser's have more resolver then others And some "implicit" ACL's - If user don't have permissions, the 3party data source will reject - datomic(eventually SQL) has some ACL support

souenzzo18:04:40

Take a look at this: https://github.com/souenzzo/eql-as#real-world-exmaple It's from export-parser-as-rest module 🙂

Reily Siegel23:04:00

If you are using Postgres, the zero-code dream can be realised with https://github.com/ReilySiegel/EQLizr (disclaimer, author). If you arent using Postgres, it should be fairly straightforward to extend, as only ANSI features are used, and can be extended to other dbs via multimethod. Note, this library currently does not support mutation.

Chris O’Donnell01:04:38

The fulcro 3 remote should look something like this (untested):

(defn fulcro-remote [parser]
  {:transmit! (fn [_ {:com.fulcrologic.fulcro.algorithms.tx-processing/keys [ast result-handler] :as send-node}]
                (let [edn (eql/ast->query ast)]
                  (go
                    (try
                      (result-handler {:transaction edn
                                       :body (<?maybe (parser {} edn))
                                       :status-code 200})
                      (catch :default e
                        (js/console.error "Pathom remote error:" e)
                        (result-handler {:body e
                                         :status-code 500}))))))})