wilkerlucio / pathom3-graphql

GraphQL Integration for Pathom 3
MIT License
17 stars 3 forks source link

Nested resolver inputs misbehave beyond a certain level #15

Closed sheluchin closed 2 years ago

sheluchin commented 2 years ago

I'm running into something a little weird with GitHub GraphQL.

This query works fine:

(p/let [result (p.eql/process github-gql-env
                {:github.Organization/login "fulcrologic"}
                ['({:github.Organization/repositories
                    [{:github.RepositoryConnection/edges
                      [{:github.RepositoryEdge/node
                        [:github.Repository/name
                         :github.Repository/nameWithOwner
                         {:github.Repository/owner [:github.RepositoryOwner/id]}]}]}]}
                   {:first 1})])]
  (doto result tap>))

Returning:

#:github.Organization
{:repositories
 #:github.RepositoryConnection
 {:edges
  [#:github.RepositoryEdge
   {:node
    #:github.Repository
    {:name "fulcro",
     :nameWithOwner "fulcrologic/fulcro",
     :owner #:github.RepositoryOwner
            {:id
             "MDEyOk9yZ2FuaXphdGlvbjMwMTAyODIz"}}}]}}

But when I try this nearly identical query through a resolver, I get an error:

(pco/defresolver shortcut
 [{{edges :github.RepositoryConnection/edges} :github.Organization/repositories
   :as input}]
 {::pco/input [{'(:github.Organization/repositories {:first 1})
                [{:github.RepositoryConnection/edges
                  [{:github.RepositoryEdge/node
                    [:github.Repository/id
                     :github.Repository/name
                     :github.Repository/nameWithOwner
                     {:github.Repository/owner [:github.RepositoryOwner/id]}]}]}]}]
  ::pco/output [{:github.Organization/all-repos
                 [:github.Repository/id
                  :github.Repository/name]}]}
 {:github.Organization/all-repos (mapv :github.RepositoryEdge/node edges)})

"Pathom can't find a path for the following elements in the query: [:github.RepositoryOwner/id] at path [:github.Organization/repositories]"

If I remove {:github.Repository/owner [:github.RepositoryOwner/id]} from the resolver input, it works. It seems like joins on other fields in the same location don't work either. For example, {:github.Repository/issues [:github.IssueConnection/totalCount]}.

Any idea what I'm doing wrong here?

wilkerlucio commented 2 years ago

Hello @sheluchin, sorry the delay, just got to read this.

I tried your first example and as you said it works here, but for the second I'm getting a different result. I had to do myself the mapping for organization for example, and without having your full sources its hard to tell if I'm running the same thing as you. So can you please provide the full sources so I can reproduce the same thing that you are running?

Thanks.

wilkerlucio commented 2 years ago

Never mind, I was able to reproduce, now have to investigate, I don't know why this is happening yet.

sheluchin commented 2 years ago

Hi @wilkerlucio. Thanks for looking into it. Please let me know if you need anything else from my end.

wilkerlucio commented 2 years ago

Maybe related issues, check together:

[{(:github.Query/search {:query "sheluchin" :type USER :first 1})
  [:github.SearchResultItemConnection/userCount
   {:github.SearchResultItemConnection/edges
    [{:github.SearchResultItemEdge/node
      [:github.User/login]}]}]}]

cause "Pathom can't find a path for the following elements in the query: [:github.User/login] at path [:github.Query/search :github.SearchResultItemConnection/edges :github.SearchResultItemEdge/node]"

wilkerlucio commented 2 years ago

@sheluchin about the Union part (the Search on Github), this just got fixed on main, wasn't related to the other issue. Now with the UNION fixed I'm moving to debug the input issue.

wilkerlucio commented 2 years ago

Fix in Pathom 3 https://github.com/wilkerlucio/pathom3/commit/aafaa06f05e54574e229146a6bebca56fd09c7cc

sheluchin commented 2 years ago

I should be able to try these fixes in a few days. Thanks very much, @wilkerlucio.

sheluchin commented 2 years ago

Can confirm both fixes worked. Thanks again!