Fork me on GitHub
#pathom
<
2024-01-18
>
grant14:01:58

I am trying to use pathom3-graphql but calling p.gql/connect-graphql on this endpoint results in

Execution error (ExceptionInfo) at edn-query-language.core/expr->ast (core.cljc:209).
Invalid expression 
If I hand the query generated by (eql-gql/query->graphql p.gql/schema-query) to Apollo Explorer I get a status 400 message with
{
  "errors": [
    {
      "message": "introspection has been disabled",
      "extensions": {
        "code": "INTROSPECTION_DISABLED"
      }
    }
  ]
}
But, querying on the Clojure side, (request {} (eql-gql/query->graphql p.gql/schema-query)), does return a giant pile of stuff so I’m not sure what is going wrong. This is the first GraphQL server I’ve had to work with so it is possibly something simple, but I tried the Star Wars endpoint to see if I had the same problem and it worked without issue.

wilkerlucio14:01:36

hello, that error message seems to indicate that introspection is disabled, can you send some parts of the giant pile you get when you call the request? introspection is required for Pathom 3 graphql to integrate, since it needs it to figure what's possible to query from that GraphQL API

grant15:01:32

Poking around I figured that was the case. I’ve requested they enable introspection and hopefully that part of the issue. What I don’t have a good feel for is what it would take to improve the error handling so that pathom3-graphql can report the introspection problem.

grant23:01:28

Looking at this further, introspection is turned on and that is why the big pile of JSON was coming back from the direct call to the server. The error from Apollo Studio was because I was hitting an intermediate GraphQL server that didn’t have introspection enabled. So, there is something there amongst the ~1500 types that pathom3-graphql doesn’t like.

grant17:01:26

p.gql/connect-graphql seems to be choking on some of the mutations. The common theme that jumps out is they all have :com.wsscode.pathom3.connect.operation/output [nil] when passed to pco/mutation. Adjusting p.gql/build-indexes to convert those to [nil]s to [] seems fix the problem. (Or, at least doesn’t blow up anymore.) @U066U8JQJ do you have a feel for if this is likely a problem with pathom3-graphql’s parsing or with the GraphQL server’s setup somehow?

grant18:01:57

Another data point, the mutations that are having issue are returning Boolean and String, at least in most cases.

wilkerlucio20:01:01

hi Grant, sorry the delay, having some busy days here, but I think I’ll be able to have a look at it later today, I dont remember doing much testing on mutations so I would not be surprised if there is a bug there

grant00:01:14

Even with a few bugs, your library is a huge help. Thank you for making it. I’m happy to help with whatever I can, but I’m brand new to GraphQL, so you’d probably have to provide some strategic/design guidance for any code help. I can at least help with any testing you need on changes.

wilkerlucio00:01:21

sure, glad to have you testing it, to be honest I dont know that much GraphQL either, at least not as an user, I have read though their docs and specification to see what I need to map, but I never actually used it directly

wilkerlucio00:01:36

and I see Apolo and others might change things slightly, so will be nice to catch any of those practical things we may need to adapt

Tyler Nisonoff20:02:31

@U0EFQAS4B any chance you have a code-sample of how you fixed this on your end? running into the same issue!

Tyler Nisonoff20:02:11

if not, i'll take a stab at it this evening and submit a PR

grant20:02:45

I have a hack that makes it work. It’s not a fix. I was hoping to actually get a fix in as a PR but haven’t had a chance to work on it. Happy to share, but I don’t have anything posted anywhere at the moment. I can try to get it up this evening though.

Tyler Nisonoff20:02:23

sounds good! I'll see when i can get to poking around as well

grant05:02:29

Hey Tyler, I didn’t get a chance to work on this, but here is the hack that I put it to the parser so I could keep moving. All it does is chunk the error condition. The error is caused by a mutation returning something like Boolean or String. The current parser code turns that into ::pco/output [nil] which the eql library doesn’t like. So if you replace the last from in build-indexes

(mapv pco/mutation (pathom-mutations env'))
with
(mapv (fn [m]
        (if (= (:com.wsscode.pathom3.connect.operation/output m) [nil])
          (pco/mutation (assoc m :com.wsscode.pathom3.connect.operation/output []))
          (pco/mutation m)))
      (pathom-mutations env'))
then it parses without exploding. I haven’t had a chance to dig in to figure out how to correctly handle things like booleans yet.