question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Invalid or incomplete schema, unknown type: query_root when using Hasura

See original GitHub issue

When attempting to build docs from a hasura graphql server I receive the follow error. It seems like spectaql does not respond well to hasura’s query_root type.

[aws-cognito:!?][austin@asus-ubuntu:~/Workspace/Sophia/platform/modules/docs]
[14:41:24] 1 $ yarn spectaql config.yaml
yarn run v1.22.5
$ /home/austin/Workspace/Sophia/platform/modules/docs/node_modules/.bin/spectaql config.yaml
/home/austin/Workspace/Sophia/platform/modules/docs/node_modules/graphql/utilities/buildClientSchema.js:117
      throw new Error("Invalid or incomplete schema, unknown type: ".concat(typeName, ". Ensure that a full introspection query is used in order to build a client schema."));
      ^

Error: Invalid or incomplete schema, unknown type: query_root. Ensure that a full introspection query is used in order to build a client schema.
    at getNamedType (/home/austin/Workspace/Sophia/platform/modules/docs/node_modules/graphql/utilities/buildClientSchema.js:117:13)
    at getType (/home/austin/Workspace/Sophia/platform/modules/docs/node_modules/graphql/utilities/buildClientSchema.js:110:12)
    at getObjectType (/home/austin/Workspace/Sophia/platform/modules/docs/node_modules/graphql/utilities/buildClientSchema.js:144:16)
    at buildClientSchema (/home/austin/Workspace/Sophia/platform/modules/docs/node_modules/graphql/utilities/buildClientSchema.js:66:51)
    at graphQLSchemaFromIntrospectionResponse (/home/austin/Workspace/Sophia/platform/modules/docs/node_modules/spectaql/app/spectaql/graphql-loaders.js:72:10)
    at module.exports (/home/austin/Workspace/Sophia/platform/modules/docs/node_modules/spectaql/app/spectaql/index.js:92:25)
    at loadData (/home/austin/Workspace/Sophia/platform/modules/docs/node_modules/spectaql/app/index.js:165:74)
    at module.exports (/home/austin/Workspace/Sophia/platform/modules/docs/node_modules/spectaql/app/index.js:169:80)
    at Object.<anonymous> (/home/austin/Workspace/Sophia/platform/modules/docs/node_modules/spectaql/bin/spectaql.js:64:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

using the default minimal config.yaml

spectaql:
# logoFile: ./test/fixtures/logo.png
# faviconFile: ./test/fixtures/favicon.png

introspection:
  url: https://api.cloud.dev-austinrivas.onework.services/v1/graphql
  # metadataFile: ./examples/data/metadata.json
  # dynamicExamplesProcessingModule: ./examples/customizations/examples

info:
  title: GraphQL API Reference
  description: Welcome to the party!
  termsOfService: https://www.example.com/terms
  contact:
    name: API Support
    url: http://www.example.com/support
    email: support@example.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html

servers:
  - url: https://example.com/graphql
    description: Production
    production: true

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

3reactions
gfviegascommented, Aug 5, 2021

Same thing happens when using url config with Absinthe

The first few lines from generated SDL file from absinthe generate sdl task is as follows:

"Represents a schema"
schema {
  query: RootQueryType
}

...

type RootQueryType {
  "A doc"
  queryFoo: Bar
  
  ...
} 
2reactions
bjunccommented, Aug 30, 2021

We are also using Absinthe, and having an issue with introspection results causing the error above (both static and dynamic). Absinthe uses the convention RootQueryType and RootMutationType as opposed to Query and Mutation.

It seems that this library has a rigid opinion on what the root type names should be; which I don’t believe is formal spec (as evidenced by the multiple versions out there, and GraphiQL not throwing an error).

I would suggest the library either accept whatever names are used as the roots, or allow the root names to be explicitly declared in the config. Otherwise, we need to resort to static introspection json, and manually swap out the root names each time (not practical).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Invalid or incomplete schema, unknown type ... - GitHub
In summary we are attempting to use spectaql to generate api documentation from our hasura api using the introspection query. It seems like...
Read more >
Top GraphQL Errors and How to fix them
Identifying error types will help quickly fix them. Clients can encounter these types of errors while communicating with the GraphQL server.
Read more >
Handling GraphQL Errors with Hasura & React
A guide to common GraphQL API & Hasura specific errors and how to handle them with React pages.
Read more >
API Reference: Common Syntax Definitions - Hasura
Common syntax definitions for the Hasura schema/Metadata API. ... QueryRootField array, Only given root fields will be enabled in the query root field....
Read more >
Actions | Hasura GraphQL Docs
Type ​ · Query action: An action of type query extends the query root of the Hasura schema. This means that you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found