Fork me on GitHub
#pathom
<
2022-02-21
>
sheluchin13:02:21

How do you do the GraphQL ... on Type thing in EQL? Trying to translate this query for Pathom:

{
  repository(name: "pathom3", owner: "wilkerlucio") {
    object(oid: "8e0a0453189bc13d045944d128248d0f2e7c5c17") {
      id
      commitUrl
      ... on Commit {
        committedDate
      }
    }
  }
}

wilkerlucio13:02:42

just ask for the attribute (in this case would be something like :ns.Commit/commitedDate, Pathom adds the ... on part automatically

🪄 1
sheluchin13:02:35

lol it's always simpler than I first guess. Thanks!

🙂 1
wilkerlucio13:02:38

this is an advantage of knowing the full context of any attribute every time 🙂

wilkerlucio13:02:45

let me know if you find any issues with it

sheluchin13:02:55

Will do. So far so good.

sheluchin15:02:40

Is there anything built in or a suggested approach for handling GraphQL pagination? Similar approach as in the https://pathom3.wsscode.com/docs/tutorials/hacker-news-scraper/#traversing-pagination?

wilkerlucio18:02:19

nothing pre-baked, you have to do your own on this

🙏 1
sheluchin21:02:12

Pulling out values from a GraphQL result with much nesting seems like a lot of work. Example:

[{:github.Organization/login login}
   ['({:github.Organization/repositories
       [:github.RepositoryConnection/totalCount
        {:github.RepositoryConnection/edges
         [{:github.RepositoryEdge/node
           [:github.Repository/id
            :github.Repository/name
            {:github.Repository/issues
             [:github.IssueConnection/totalCount]}
            {:github.Repository/pullRequests
             [:github.PullRequestConnection/totalCount]}
            {:github.Repository/defaultBranchRef
             [:github.Ref/name
              {:github.Ref/target
               [{:github.Commit/history
                 [:github.CommitHistoryConnection/totalCount]}]}]}]}]}]}
      {:first 2})]])
Result:
{:github.Organization/repositories {:github.RepositoryConnection/totalCount 29
                                         :github.RepositoryConnection/edges [{:github.RepositoryEdge/node {:github.Repository/id "MDEwOlJlcG9zaXRvcnk5NzAzMjE1OA=="
                                                                                                           :github.Repository/name "fulcro"
                                                                                                           :github.Repository/issues {:github.IssueConnection/totalCount 270}
                                                                                                           :github.Repository/pullRequests {:github.PullRequestConnection/totalCount 233}
                                                                                                           :github.Repository/defaultBranchRef {:github.Ref/name "develop"
                                                                                                                                                :github.Ref/target {:github.Commit/history {:github.CommitHistoryConnection/totalCount 4436}}}}}
                                                                             {:github.RepositoryEdge/node {:github.Repository/id "MDEwOlJlcG9zaXRvcnk5NzAzNjU0Nw=="
                                                                                                           :github.Repository/name "fulcro-spec"
                                                                                                           :github.Repository/issues {:github.IssueConnection/totalCount 16}
                                                                                                           :github.Repository/pullRequests {:github.PullRequestConnection/totalCount 7}
                                                                                                           :github.Repository/defaultBranchRef {:github.Ref/name "develop"
                                                                                                                                                :github.Ref/target {:github.Commit/history {:github.CommitHistoryConnection/totalCount 709}}}}}]}}
Is there any sugar for making life easier here? I was thinking of using https://github.com/escherize/tracks as a helper.

sheluchin21:02:02

Or maybe just providing a detailed ::pco/output is enough? :thinking_face:

Björn Ebbinghaus22:02:00

Maybe you could add a resolver, that connects ˋrepositoriesˋ directly to the repository? Input repositories, output repository id Then you could skip edges and node

wilkerlucio00:02:43

this is more about GraphQL design for pagination, which adds these extra steps, like @U4VT24ZM3 said, you may be able to shortcut by writing resolvers that simplify the request. At this point I think we need to verify if we can properly forward the params in this situation

wilkerlucio01:02:39

I think this falls in the same domain as this issue, but instead of forwarding sub-queries parts, we may want something to point how to forward params: https://github.com/wilkerlucio/pathom3/issues/84

sheluchin10:02:20

Thanks for the input. A shortcut resolver seems like it makes the most sense right now, but it does feel like there is potential for a shorter description.

sheluchin17:02:27

I'm not sure I understand the shortcut resolver approach. Is the idea that I should: • create a resolver that takes :gh.Organization/repositories • have that resolver do the work requesting additional levels down (edges and nodes, down to :Repository/id), and flattening and return the results Could someone please elaborate or link me to some source or documentation with a relevant example?