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)
Could you share a reproduction repo or CodeSandbox?
@ardatan Yes, you can preview the code here https://codesandbox.io/s/pensive-brahmagupta-cjvz7?file=/src/index.js
https://codesandbox.io/s/rough-glitter-b8hbe?file=/graphql/types/Filter.graphql
Removing Query.* fixed it so there is bug related to Query.* usage. Thanks for the reproduction.
@ardatan Thanks
Let's keep it open because it seems like a bug. We should be able to support an import statement like that.
I'm also having this error, but I'm not using *. I encountered it while transitioning from graphql-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!
@Nathan-Schwartz Thank you for the reproduction! We'll take a look and let you know the result soon.
Hi, I have same issue as @Nathan-Schwartz described. Did anyone find a solution? thx
Hey @ardatan are there any updates on this issue?
Most helpful comment
Hi, I have same issue as @Nathan-Schwartz described. Did anyone find a solution? thx