Altair: Looks like the GraphQL schema is invalid

Created on 12 May 2020  ·  8Comments  ·  Source: imolorhe/altair

Describe the bug
This error pops up countless times, and it gives no indication on what the issue is. I also found no way to ignore these messages, so the app is kinda impossible to use with this popping up on every request.

On GraphQL playground with the same URL, I see the Schema and Docs (to the right) just fine though: https://laravel.trafficfox.app/graphql-playground

To Reproduce
Steps to reproduce the behavior:
Send a post request to: https://laravel.trafficfox.app/graphql

Expected behavior
Well, at least a message telling me what the issue is.

Screenshots
https://i.imgur.com/aqOpQDq.png

Desktop (please complete the following information):
MacOS.

enhancement

Most helpful comment

Hey @aarona, thanks for the detailed explanation. Indeed displaying the actual error message might be helpful for developers to figure out the problem. Also stacking up error messages might not be the best idea. I see these as two potential issues that should be resolved:

  • adding original error message in error alert
  • alternative to stacking alert messages

All 8 comments

👋🏾Thanks for opening your first issue here! Be sure to follow the issue template! ✌🏾

Hey @trafficfox :wave:,

Thank you for opening an issue. We will get back to you as soon as we can.
Also, check out our Open Collective and consider backing us - every little help counts!

Hey @trafficfox, I tried checking the GraphQL endpoint but I get a File not found error

I'm also getting this error. My schema is fine, not errors logs on my server side (Ruby on Rails). I'm using Ubuntu 20.04.

Just so you know, this started happening about two days after I began using the application. It wouldn't be so bad but it keeps generating these error messages every couple seconds and sometimes it generates about 10 stacked error messages at the same time, all of them are the same covering the app and making it totally unusable now. Restarting the application doesn't do anything to fix it either.

I'll switch back to the GraphiQL desktop app for now but this project looks really promising. More features than GraphiQL by far (Its like Postman for GQL almost) and would much rather use your app.

So I think I might have found the problem. I tried playing around with GraphiQL's Rails engine web interface and its actually giving me a proper error on the client side. Apparently I inherited an InputType from Types::BaseObject instead of Types::BaseInputObject. If I make a request for documentation, I get the following response in my logs:

Started GET "/graphiql" for ::1 at 2020-05-18 22:55:54 -0700
Processing by GraphiQL::Rails::EditorsController#show as HTML
  Parameters: {"graphql_path"=>"/graphql"}
  Rendering /home/aaron/.rvm/gems/ruby-2.6.5@appt/gems/graphiql-rails-1.7.0/app/views/graphiql/rails/editors/show.html.erb
  Rendered /home/aaron/.rvm/gems/ruby-2.6.5@appt/gems/graphiql-rails-1.7.0/app/views/graphiql/rails/editors/show.html.erb (Duration: 1.9ms | Allocations: 2031)
Completed 200 OK in 3ms (Views: 2.3ms | ActiveRecord: 0.0ms | Allocations: 2341)


Started POST "/graphql" for ::1 at 2020-05-18 22:55:54 -0700
Processing by GraphqlController#execute as */*
  Variables: {}


      query IntrospectionQuery {
.... removed for brevity
      }

Completed 200 OK in 87ms (Views: 7.3ms | ActiveRecord: 0.0ms | Allocations: 34381)

Everything looks fine. This is why I thought I wasn't doing anything wrong on my end. However, look at the error that is returned in the section with my results should be:

Error: Introspection must provide input type for arguments.
    at invariant (http://localhost:3001/assets/graphiql/rails/application-6f03c7a92432765b0fbe671bfb7a292ee6c37e6704b6e6ac95587e45676bbf72.js:26432:11)
    at getInputType (http://localhost:3001/assets/graphiql/rails/application-6f03c7a92432765b0fbe671bfb7a292ee6c37e6704b6e6ac95587e45676bbf72.js:34152:67)
    at buildInputValue (http://localhost:3001/assets/graphiql/rails/application-6f03c7a92432765b0fbe671bfb7a292ee6c37e6704b6e6ac95587e45676bbf72.js:34296:16)
    at http://localhost:3001/assets/graphiql/rails/application-6f03c7a92432765b0fbe671bfb7a292ee6c37e6704b6e6ac95587e45676bbf72.js:26576:31
    at Array.reduce (<anonymous>)
    at keyValMap (http://localhost:3001/assets/graphiql/rails/application-6f03c7a92432765b0fbe671bfb7a292ee6c37e6704b6e6ac95587e45676bbf72.js:26575:15)
    at buildInputValueDefMap (http://localhost:3001/assets/graphiql/rails/application-6f03c7a92432765b0fbe671bfb7a292ee6c37e6704b6e6ac95587e45676bbf72.js:34290:36)
    at fields (http://localhost:3001/assets/graphiql/rails/application-6f03c7a92432765b0fbe671bfb7a292ee6c37e6704b6e6ac95587e45676bbf72.js:34265:16)
    at resolveThunk (http://localhost:3001/assets/graphiql/rails/application-6f03c7a92432765b0fbe671bfb7a292ee6c37e6704b6e6ac95587e45676bbf72.js:30634:40)
    at GraphQLInputObjectType._defineFieldMap (http://localhost:3001/assets/graphiql/rails/application-6f03c7a92432765b0fbe671bfb7a292ee6c37e6704b6e6ac95587e45676bbf72.js:31105:20)

So I fixed my issue and those errors went away. I think that maybe you need more specific exception handling with the error messages and possibly emulate what GraphiQL does by putting the errors in the results window.

Hey @aarona, thanks for the detailed explanation. Indeed displaying the actual error message might be helpful for developers to figure out the problem. Also stacking up error messages might not be the best idea. I see these as two potential issues that should be resolved:

  • adding original error message in error alert
  • alternative to stacking alert messages

Not sure whats going on with the stacked messages but I know GraphiQL hits the API on every key press when entering the endpoint URL (something I cannot stand about it tbh). Possibly look into suppressing rapidly recurring error messages coming back from the server? Also, I think putting the server error message into the results pane like GraphiQL seems to me to be the best way to handle it.

On a side note: Now that I figured out my API did have a schema problem, I'm back to using Altair again. Would like to contribute to this project if I get some free time or at the very least give some input on the UX. This is a really great app and I love that its a snap app (I'm an Ubuntu user)

Any form of contributions are welcome 🙂

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MCSH picture MCSH  ·  7Comments

sneko picture sneko  ·  10Comments

someden picture someden  ·  9Comments

isaachvazquez picture isaachvazquez  ·  8Comments

DaniloCaruso picture DaniloCaruso  ·  3Comments