Fork me on GitHub
#fulcro
<
2023-04-22
>
oliver10:04:03

Hi everyone, after spending considerable time on the docs, I was going to start a toy project to get a feel for the fulcro way. To keep things simple on the backend I wanted to adapt an existing GraphQL endpoint as described in the docs https://book.fulcrologic.com/fulcro2/#_fulcro_and_graphql. I'm running into a strange dependency issue, however, once I set up a minimal project. These are my dependencies:

{com.fulcrologic/fulcro {:mvn/version "3.6.3"}
 com.wsscode/pathom {:mvn/version "2.4.0"}}
For now, I have a single cljs namespace with the following content:
(ns app.client
  (:require
   [com.wsscode.pathom.fulcro.network :as pfn]
   [fulcro.client :as fc]))

(fc/make-fulcro-client
 :networking
 {:remote
  (pfn/graphql-network
   {::pfn/url "my-graph-ql-endpoint"})})
Starting compilation I get:
The required namespace "fulcro.client.network" is not available, it was required by "com/wsscode/pathom/fulcro/network.cljs
It seems, indeed, that there is no such namespace as fulcro.client.network in the fulcro repo. Acknowledging that com.wsscode.pathom.fulcro.network is marked as experimental, is the technique shown in the docs currently viable, or not? If so, what may be the issue here? Many thanks in advanceā€¦ I'm really excited to get a first toy project with fulcro off the ground!

tony.kay19:04:07

Fulcro client is part of version 2.x. the transition to version 3 was a rewrite that is 95% API alike, but all in new name spaces to prevent accidents. All new nses start with com.fulcrologic

tony.kay19:04:59

The spirit of that idea is correct, but you may be using code that was written for fulcro 2.x. If you're trying to truly get a simple toy project off the ground, I'd recommend going with the template project and stick with eql

oliver20:04:42

Many thanks for the clarification! My project is a toy insofar as fulcro is overkill for it (the most sensible solution would likely be a static site). But when I do stuff for friends and family I usually try to get a learning experience out of it and the stakes are low. The idea is to set up https://directus.io/ as a headless CMS, which exposes a GraphQL interface and to then access it read-only. I was under the impression that the approach I attempted would somehow act as a translator between GraphQL and EQL, such that I 'd be able to write the latter to query the CMS. But your reply makes me think this presumption was mistaken. Is there any such thing as a GraphQL<>EDN adapter? If not, the only option would be to write the resolvers that in turn query one of three things: 1. The Directus SQL DB; 2. The Directus GraphQL endpoint; 3. The Directus RestAPI. I welcome any pointers you may have on these routes, but, in any case, I thank you for chiming in and unblocking me on the current attempt!

oliver20:04:28

Just to potentially spare you some time, I have now found the GraphQL integration for pathom, which looks quite promising: https://pathom3.wsscode.com/docs/tutorials/graphql-integration/