0

We have an existing postgresql database with data and we are experimenting with postgraphile as a graphql API. We are running into an error that is leaving us scratching our head. the server runs fine but we get the following:

postgraphile -c postgres://username:password@localhost:5432/my_db                                                                

PostGraphile server listening on port 5000                                                                                                                 

  ‣ Connected to Postgres instance postgres://localhost:5432/my_db                                                                                          
  ‣ Introspected Postgres schema(s) public                                                                                                                      
  ‣ GraphQL endpoint served at http://localhost:5000/graphql                                                                                                    
  ‣ GraphiQL endpoint served at http://localhost:5000/graphiql                                                                                                  

* * *                                                                                                                                                           

An error occurred, it might be okay but it doesn't look like the error we were expecting... run with envvar 'DEBUG="graphile-build:warn"' to view the error     
An error occurred, it might be okay but it doesn't look like the error we were expecting... run with envvar 'DEBUG="graphile-build:warn"' to view the error     

Error: Query root type must be provided.                                                                                                                        
    at assertValidSchema (C:\Users\user\AppData\Roaming\npm\node_modules\postgraphile\node_modules\graphql\type\validate.js:78:11)                      
    at Object.validate (C:\Users\user\AppData\Roaming\npm\node_modules\postgraphile\node_modules\graphql\validation\validate.js:61:35)                  
    at parseQuery (C:\Users\user\AppData\Roaming\npm\node_modules\postgraphile\build\postgraphile\http\createPostGraphileHttpRequestHandler.js:208:48)  
    at Promise.all.paramsList.map (C:\Users\user\AppData\Roaming\npm\node_modules\postgraphile\build\postgraphile\http\createPostGraphileHttpRequestHandler.js:469:63)                                                                                                                                                  
    at Array.map (<anonymous>)                                                                                                                                  
    at requestHandler (C:\Users\user\AppData\Roaming\npm\node_modules\postgraphile\build\postgraphile\http\createPostGraphileHttpRequestHandler.js:435:52)                                                                                                                                   
    at <anonymous>                                                                                                                                              
    at process._tickCallback (internal/process/next_tick.js:188:7) 

and when we navigate to localhost:500/graphiql we see a a "no schema available" in the documentation explorer.

is the query root the publicschema? or what are we missing?

Joseph
  • 351
  • 1
  • 6
  • 17
  • What happens when you run `DEBUG="graphile-build:warn" postgraphile -c ...`? I’m guessing at this point that there’s multiple versions of GraphQL in node_modules and that’s causing an issue, but it might be something else. – Benjie Jul 07 '18 at 07:47
  • we removed postgraphile then readded the package, same problem. we also tested in a simple database with three tables, that one works fine. that is why we are unsure what is causing this error. – Joseph Jul 07 '18 at 16:09
  • If you run it with the environment variable listed above then it will output additional error information which should give you a hint what is wrong. I’d love to know what it is so that I can improve the error reporting. – Benjie Jul 07 '18 at 22:41
  • the query root is not the *public* - look at the forum example, it doesn't make use of *public* at all. -- it would help if you would post your schema. There's obviously something wrong with it. – Tom Jul 08 '18 at 19:44

1 Answers1

0

Newer versions of PostGraphile have much more helpful error messages, often including a suggested solution. The "An error occurred" errors like those above now also contain a preview of the underlying error which helps with diagnosis.

There are instructions here on how to set the DEBUG environmental variable here: https://www.graphile.org/postgraphile/debugging/#debug-envvars

Here's how you might do it in Linux, macOS or Windows:

# Bash (Linux, macOS, etc)
export DEBUG="graphile-build:warn" postgraphile -c postgres://username:password@localhost:5432/my_db

# Windows Console
set DEBUG=graphile-build:warn & postgraphile -c postgres://username:password@localhost:5432/my_db

# Windows PowerShell
$env:DEBUG = "graphile-build:warn"; postgraphile -c postgres://username:password@localhost:5432/my_db
Benjie
  • 7,701
  • 5
  • 29
  • 44