pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
frankitox 2020-11-24T14:15:32.334800Z

So, I'm wondering how people handles HTTP status codes when using pathom. I'm using pedestal so I found some https://github.com/jlesquembre/pathom-pedestal/blob/18c27aa84526a8610e6f91247aae674723f599e5/src/pathom/pedestal.clj#L45-L49 that just always returns 200s. Is this a common practice in Pathom/GraphQL? For example, under certain auth conditions I'd like to return a 401 with a bit of info about the error.

souenzzo 2020-11-24T18:11:33.339400Z

@franquito in a #fulcro app, your communication with the server is via EQL, "not via HTTP" HTTP will return 200 always that "the EQL request has been processed" if your EQL Query has a not allowed access, you will return a 200 with a response that contains that "not allowed" message. But it's nothing about #pathom , it's more about "how we develop SPA in 2020" I use #pathom to deliver a REST API, returning different codes for each request

wilkerlucio 2020-11-24T20:19:50.340500Z

released [com.wsscode/pathom "2.3.0-alpha19"], this gives a fixes a problem with the jar, that previously included the compiled js data, the jar is reduced from 9.1MB to 103kb

👍 9
frankitox 2020-11-24T20:33:41.340700Z

I see. I'm using re-frame only with the POST /api endpoint now (that's the basic implementation I've seen in the wild). Now I'm looking to add JWT to the mix, which means setting headers. In this REST API you reify the status codes in Pathom? For example, a resolver or a mutation may return a :response/status and you use that with the HTTP server?

souenzzo 2020-11-24T20:43:22.341100Z

@franquito a bit of my opinion When you send a query with a mutation with a mutation, if the mutation run¹, it will return 200. It say nothing about success/fail of the mutaion. it says about the success of execution of the query IMHO, the mutation should return something like {my/mutation {:fail {:msg "can't because x" :some-explain {..data..}}}} ¹ - mutation run: (parser env tx) => map? not trow

souenzzo 2020-11-24T20:52:58.341300Z

But it's a open system. #fulcro is just one impl. My current pathom usage is a SSR app where I usa "raw" HTML form's to create POST's and programmatically turn these POST's into an EQL tx, return 303 -> Location and get a new page (rended by hiccup) I all "EQL tx" a "query that contains a mutation"

frankitox 2020-11-24T21:02:07.341500Z

Crap, I'm still very confused :thinking_face: but I get your idea of 200s expressing a successful execution. The biggest question is how much of your system you end up representing with the keywords. I think I need more hammock time here, thank you for the helpful thoughts Enzzo!

souenzzo 2020-11-24T21:14:20.341800Z

Thinking about "network stack": Your HTTP server do not send a TCP ACK when your application fails, it send's a TCP OK with a HTTP FAIL Your EQL server do not send 400 when the mutation fails, it send a HTTP OK with a ::p/errors