graphql-tools: Unknown type
I have a problem creating pagination. When creating types, it appears to me that the type is Unknown
schema:
# import Post from "../types/Post.graphql"
# import PageInfo from "../types/PageInfo.graphql"
type Edge {
cursor: String!
node: Post!
}
type PostsCursor {
edges: [Edge!]!
pageInfo: PageInfo!
totalCount: Int!
}
type Query {
posts(filter: String, first: Int, after: String): PostsCursor!
}
logs:
Error: Unknown type "Edge".
Unknown type "PageInfo".
at assertValidSDL (/Users/youhosi/Dev/site/node_modules/graphql/validation/validate.js:107:11)
at Object.buildASTSchema (/Users/youhosi/Dev/site/node_modules/graphql/utilities/buildASTSchema.js:45:34)
at makeSchema (/Users/youhosi/Dev/site/node_modules/@graphql-tools/merge/index.cjs.js:917:99)
at Object.mergeSchemas (/Users/youhosi/Dev/site/node_modules/@graphql-tools/merge/index.cjs.js:900:12)
at loadSchemaSync (/Users/youhosi/Dev/site/node_modules/@graphql-tools/load/index.cjs.js:623:26)
at Object.<anonymous> (/Users/youhosi/Dev/site/server/graphql/index.js:7:16)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (/Users/youhosi/Dev/site/server/server.js:15:16)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (13 by maintainers)
Commits related to this issue
- Add failing test case. This proves assumption in https://github.com/ardatan/graphql-tools/issues/1591#issuecomment-827362605 — committed to steponas/graphql-tools by steponas 3 years ago
- fix(import): handle nested imports correctly (#2883) * Add failing test case. This proves assumption in https://github.com/ardatan/graphql-tools/issues/1591#issuecomment-827362605 * fix(import): h... — committed to ardatan/graphql-tools by steponas 3 years ago
Will be available in the latest release in a few minutes! Thanks for the failing test!
Hi, I have same issue as @Nathan-Schwartz described. Did anyone find a solution? thx
I’m also having this error, but I’m not using
*
. I encountered it while transitioning fromgraphql-import
to@graphql-tools/load
per the docs here. The issue started occurring after the migration and I didn’t make any other changes.I forked the sandbox used earlier and created a simple repro here. (The server should start up successfully without any code changes, but you may have to fork to get it to working.)
To repro the issue:
/graphql/queries/posts.graphql
and save the fileThe app should crash with
Error: Unknown type "Post"
.I’ve tried ordered the
posts.graphql
file such that everything is defined before it is used, but it doesn’t seem to help.Am I doing anything incorrectly? Any help would be appreciated.
Thanks!
I am updating this issue to stage-2. Thank you for failing test @steponas !
@Nathan-Schwartz Thank you for the reproduction! We’ll take a look and let you know the result soon.
https://codesandbox.io/s/rough-glitter-b8hbe?file=/graphql/types/Filter.graphql
Removing
Query.*
fixed it so there is bug related toQuery.*
usage. Thanks for the reproduction.@ardatan Yes, you can preview the code here https://codesandbox.io/s/pensive-brahmagupta-cjvz7?file=/src/index.js