Fork me on GitHub
#pathom
<
2022-02-02
>
wilkerlucio00:02:50

Released Pathom 3 2022.02.01-alpha 2022.02.01-1-alpha, this release contains some important fixes on optionals, thanks to @dehli for those reports • Fix error trigger when a dependency of some optional attribute fails (bug #126) • Fix planning errors on optional nested inputs (bug #127)

🎉 3
dehli00:02:13

Thanks for fixing them so quickly!

🙏 1
wilkerlucio00:02:30

fix -1 to remove a debug tap> that got in the release

👍 1
jgood13:02:15

@wilkerlucio I'm running into a weird issue. I'm using the async interface p.a.eql. When any resolver has a go block and the request has a palceholder: The resolver fails with :pcr/attribute-errors Error: Required attributes missing if the dependencies don't rely on some placeholder provided data -- even if the resolver has no dependencies.

wilkerlucio14:02:34

hello, thanks, can you open an issue with a repro example please?

👍 1
wilkerlucio00:02:40

ah, sorry, I just realized you are trying to use core.async there, have you imported the promesa bridges library? https://github.com/wilkerlucio/promesa-bridges

wilkerlucio00:02:06

Pathom 3 uses Promesa (isntead of Core.async) as the async manager tool, the promesa-bridges can make core.async compatible with promesa

wilkerlucio00:02:13

please let me know if that's the case, or if its something else

jgood12:02:26

I didn't include the imports in the example but I do use [com.wsscode.promesa.bridges.core-async]

jgood12:02:56

The async resolver works as long as the resolver has an input that depends on something in the placeholder.

jgood13:02:17

I'm feeling more confident this is a bug in pathom and I've updated the issue example to include imports and more queries to show the problem.

wilkerlucio13:02:45

thanks, the example looks great, I'll have closer look later today

👍 1
wilkerlucio14:02:59

sorry the delay, a quick update I can confirm the issue when using go blocks in the scenario that you described

wilkerlucio14:02:30

I tested doing the same using promesa futures, and in this case it seems to work fine, I'll have to look further to understand what's causing the distinction

sheluchin14:02:13

I'm running into an issue when executing this query through the latest viz: GraphQL version (works in the GH Explorer):

{
  viewer {
    repositories(first: 1) {
      edges {
        node {
          name
          issues {
            totalCount
          }
        }
      }
    }
  }
}
[{:github.Query/viewer
  [{(:github.User/repositories {:first 1})
    [{:github.RepositoryConnection/edges
      [{:github.RepositoryEdge/node
        [:github.Repository/name
         {:github.Repository/issues
          [:github.IssueConnection/totalCount]}]}]}]}]}]

wilkerlucio14:02:03

this seems to be something weird with the Github implementation, Pathom GraphQL integration leverages the types to allow some polymorphic queries with ease, but seems like Github is not happy with that... here is the query that Pathom generates for this case:

query {
  __typename
  ... on Query {
    viewer {
      __typename
      ... on User {
        repositories(first: 10) {
          __typename
          ... on RepositoryConnection {
            edges {
              __typename
              ... on RepositoryEdge {
                node {
                  __typename
                  ... on Repository {
                    name
                    issues {
                      __typename
                      ... on IssueConnection {
                        totalCount
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

wilkerlucio14:02:37

I wanna investigate closer where the real problem is, up to some level it works, but after it seems to break (just asking the name from viewer works fine for example)

sheluchin14:02:12

Yes, it breaks when walking into the :gh.Repo/issues edge and asking for the totalCount. Up to that point I didn't have any issues so far.

wilkerlucio14:02:56

I think a way to improve that on Pathom side is to avoid using ... on Type when the attribute is targeting the same type as the current context

wilkerlucio14:02:19

(I tried removing the ... on IssueConnection part and it did the trick to fix it)

sheluchin17:02:54

Thanks @wilkerlucio. Glad to have alerted you of the issue. I'm looking forward to making use of the GraphQL stuff in Pathom 🙂

wilkerlucio17:02:15

I'll try to get to that later today, I have already an idea on how to fix it 🙂

metal 1
sheluchin22:02:33

@wilkerlucio thank you, sir 🙏 I will experiment some more with the GH API and let you know if there are other surprises.

👍 1
wilkerlucio00:02:07

@alex.sheluchin since you playing with Github, I just made a fix to root entries (old ident-map), and updated the example on Github to allow a query like this to work:

(p.eql/process env
  {:github.User/login "wilkerlucio" :github.Repository/name "pathom3"}
  [:github.Repository/homepageUrl])
Updated example https://github.com/wilkerlucio/pathom3-graphql/blob/main/demos/com/wsscode/pathom3/graphql/demos/github.clj

sheluchin19:02:51

Hey @wilkerlucio, I'm trying to make the root entries example you showed work, but not quite getting it. I'm presuming in Pathom3 it's basically the same as Pathom2? ie the wrapper function to build the ident as recommended in the Pathom2's https://blog.wsscode.com/pathom/v2/pathom/2.2.0/graphql/fulcro.html#MultiInputIdents still applies?

wilkerlucio19:02:10

@alex.sheluchin yes, but a bit different, in Pathom 3 we can now send root data much easier than we could in Pathom 2, the think about root entries mapping is that you can access GraphQL entry points without using the entry points, so you can for example provide a user login and ask for user data (instead of nesting over user(login: ...))

wilkerlucio19:02:58

the code from the linked example, plus the

(p.eql/process env
  {:github.User/login "wilkerlucio" :github.Repository/name "pathom3"}
  [:github.Repository/homepageUrl])
should work, have you seem something bad while trying it?

wilkerlucio20:02:27

but about wrapping funcitons, no need to make them nowadays

wilkerlucio20:02:57

that syntax doesn't even work anymore, idents can only send a single value, you can now use placeholders to send multiple data points, but there are also other options as: 1. second argument in p.eql/process to send data to the root 2. if using boundary interface, you can send the request as: {:pathom/entity {:entity/data "foo"} :pathom/tx [:query]}

sheluchin20:02:34

@wilkerlucio I think I have something wrong with my setup right now. All queries just give me:

#object[java.util.concurrent.CompletableFuture 0x35e53559 "rejected"]
When I inspect env:
#object[clojure.lang.Var$Unbound 0x64a74b92 "Unbound: #'com.wsscode.pathom3.graphql.demos.github/env"]
And when trying to re-assign it with make-env, I get:
Execution error (AssertionError) at com.wsscode.pathom3.connect.indexes/register-mutation (indexes.cljc:194).
Assert failed: Tried to register duplicated mutation: com.wsscode.pathom.viz.ws-connector.pathom3/request-snapshots
(nil? (com.wsscode.pathom3.connect.indexes/mutation indexes op-name))
And it seems to stay that way after I shut everything down and retry. Do you know how I can get around it? Also, queries do work from Viz. Is it possible to use your snippet there? It expects a single vector/EQL query..

wilkerlucio21:02:22

from viz you can use the new panel below the query to provide initial data

wilkerlucio21:02:44

can you give a full example of the thing you see? are you using JVM or Browser pathom ?

sheluchin21:02:39

I am on JVM, just following the example in com.wsscode.pathom3.graphql.demos.github.

sheluchin21:02:22

The modification I've made is here:

(defn make-env []
  (-> {}
      (p.gql/connect-graphql
        {::p.gql/namespace        "github"
         ::p.gql/root-entries-map {"repository" {"name"  ["Repository" "name"]
                                                 "owner" ["User" "login"]}
                                   "user"       {"login" ["User" "login"]}}}
        request)
      (p.connector/connect-env {::pvc/parser-id ::env
                                ::p.connector/async? true})
      ((requiring-resolve 'com.wsscode.pathom.viz.ws-connector.pathom3/connect-env)
       "gql-github")))
I've restarted everything, reconnected to my repl, and go to eval (def env (make-env)). This then gives me:
Execution error (AssertionError) at com.wsscode.pathom3.connect.indexes/register-mutation (indexes.cljc:194).
Assert failed: Tried to register duplicated mutation: com.wsscode.pathom.viz.ws-connector.pathom3/request-snapshots
(nil? (com.wsscode.pathom3.connect.indexes/mutation indexes op-name))
That's the full thing.

sheluchin21:02:59

Removing the call to p.connector/connect-env from make-env does allow me to use that root entry query from Viz.

sheluchin21:02:25

No luck in my REPL though. I must be missing something basic about how to use it.

sheluchin21:02:39

Sorry @wilkerlucio, gotta be something on my end. I've set up reveal for tap> and now I can see the responses properly, and indeed the root entry query works! As for Viz, I didn't realize that bottom Entity Data window was for that purpose. It makes sense now. Appreciate your explanation. I will test a bunch of other GH queries and will let you know if anything doesn't work - hopefully stuff that isn't just related to my setup 🙂

wilkerlucio21:02:59

I see you are setting up the connector with ::p.connector/async? true, unless you using the async runner, that will make the thing fail

wilkerlucio21:02:07

also, the last line, the requiring-resolve is also adding the connector, so that's adding the connector twice, which will give the error of duplicated things you see

wilkerlucio21:02:39

using the require-resolve is a way that I do it so I don't have to :require the viz namespace (makes easy to put in/out)

imre14:02:54

Hey @wilkerlucio, is there any kind of pathom2->3 migration guide available somewhere?

wilkerlucio17:02:46

nothing available at this time

wilkerlucio17:02:23

but a summary: in general the resolvers should work fine, attention need to be taken if use stuff from env on the resolvers, also plugins would rewrite some rewriting because the entry points are different now

imre17:02:27

on resolvers: if I read it correctly, input specification changed a bit as well, right?

wilkerlucio17:02:06

yes, minor change, they changed from sets to vectors (EQL to be more precise, now that they accept nested inputs)

wilkerlucio17:02:43

writing a function to convert one to another is trivial (except on the case of env usage, then it needs to figure the alternative on Pathom 3)

imre17:02:03

Thank you for the summary!

👍 1