pathom

Tyler Nisonoff 2023-11-16T17:15:18.884729Z

Been working with the pathom3 graphql integration In the demo examples, I see authorization tokens being used in the github example, but the token is an env variable constant for any request. In my example, I have a pathom plugin authenticating the user from a JWT, and I want to pass this user-specific account information to my backend graphql instance, ideally via headers. However, p.gql/connect-graphql 's request fn only takes in the query, not the environment, so I'm having trouble figuring out how to pass this information along. Would a PR be accepted that allows for the environment to be passed into this fn as well? or is there a better way to accomplish this?

wilkerlucio 2024-01-03T14:46:10.770789Z

hello Tyler, sorry, all the end of year things made me lose track of this, I'll have a look later today 😉

Tyler Nisonoff 2024-01-03T17:33:20.532249Z

no problem at all!

wilkerlucio 2024-01-04T01:29:52.582229Z

merged, thanks!

❤️ 1
Tyler Nisonoff 2024-01-04T01:30:11.719299Z

Awesome!

Tyler Nisonoff 2023-11-16T18:46:13.452379Z

essentially something that looks like:

(defn auth-header-map [env]
  (if-let [acct-info (lib.auth/get-account-info env)]
    acct-info
    {}))

(defn request-vb-graphql
  "helper fn required by p.gql/connect-graphql to make graphql requests"
  [env query]
  #?(:clj
     (let [{:keys [host port]} (:config config)]
       (-> @(http/request
             {:url     (str "http://" host ":" (str port) "/graphql")
              :method  :post
              :headers (merge {"Content-Type" "application/json"
                               "Accept"       "*/*"}
                              (auth-header-map env))
              :body    (json/write-str {:query query})})
           :body
           json/read-str))))

wilkerlucio 2024-02-08T15:11:28.666579Z

hey @tylernisonoff, sorry the delay. I actually tried to do this the other day, but there are some new requirements on clojars that I have to fix to make a new release, I'll let you know once I get to it

Tyler Nisonoff 2024-02-08T15:21:42.262149Z

All good appreciate it!

Tyler Nisonoff 2024-01-23T22:19:57.719179Z

@wilkerlucio would you be up for cutting a new release of https://github.com/wilkerlucio/pathom3-graphql given this is merged?

Tyler Nisonoff 2024-01-02T21:30:49.235929Z

Hey Wilker, was wondering if you're still interested in the above PR? No real urgency on my part, just wanted to check in case it slipped your mind. Let me know if/how i can help get it over the finish line!

wilkerlucio 2023-11-26T12:31:39.684679Z

hello @tylernisonoff, yeah, I think we will need to add also the environment, happy to discuss the change on a PR

Tyler Nisonoff 2023-11-26T21:52:41.174709Z

Sounds good! gonna Open a PR with a breaking change here, but happy to discuss non-breaking alternatives and make the proper changes -- figured this'll just be a good starting point https://github.com/wilkerlucio/pathom3-graphql/pull/17