Attempts to load all resolvers fail with Generating schema error
async function bootstrap() {
const schema = await buildSchema({
resolvers: [__dirname + "/**/*.resolver.ts"],
});
// other initialization code, like creating http server
}
GeneratingSchemaError has a details property of type ReadonlyArray<GraphQLError>.
I think that it might be useful in debugging the reason of this error 馃槈
@snaquaye
Have you figured out what was the problem?
Could you paste here the content of details property with GraphQL errors?
My bad! Trying to debug it, i noticed it is now working.
@snaquaye Do you remember what your actually solution was here?
It appears that GeneratingSchemaError.details needs to be logged explicitly under these circumstances since it is not logged when a UnhandledPromiseRejectionWarning occurs.
export async function generateSchema(): Promise<GraphQLSchema> {
return buildSchema({
resolvers: [FunResolver]
})
```
UnhandledPromiseRejectionWarning: Error: Generating schema error
... (no details)
## After
```ts
export async function generateSchema(): Promise<GraphQLSchema> {
try {
const schema = await buildSchema({
resolvers: [FunResolver]
})
return schema
} catch (e) {
console.error(e)
throw e
}
}
GeneratingSchemaError: Generating schema error
...
details: [
GraphQLError: Type Query must define one or more fields.
Most helpful comment
It appears that
GeneratingSchemaError.detailsneeds to be logged explicitly under these circumstances since it is not logged when a UnhandledPromiseRejectionWarning occurs.Workaround
Before
```
UnhandledPromiseRejectionWarning: Error: Generating schema error
... (no details)