Closed
Description
To Reproduce
Steps to reproduce the behavior:
- My GraphQL schema:
type Query {
optional: Result
}
type Result {
mandatory: String!
}
- My GraphQL operations:
const resolvers: Resolvers = {
Query: {
optional: () => Promise.resolve("x").then(r => (r ? {} : null))
}
};
Expected behavior
null
is a valid result type, but I get:
src/resolvers.ts(4,3): error TS2322: Type '{ optional: () => Promise<Result | Promise<Result> | {} | null>; }' is not assignable to type 'QueryResolvers<MyContext, {}>'.
Types of property 'optional' are incompatible.
Type '() => Promise<Result | Promise<Result> | {} | null>' is not assignable to type 'ResolverFn<Maybe<ResolverTypeWrapper<Result>>, {}, MyContext, {}> | StitchingResolver<Maybe<ResolverTypeWrapper<Result>>, {}, MyContext, {}> | undefined'.
Type '() => Promise<Result | Promise<Result> | {} | null>' is not assignable to type 'ResolverFn<Maybe<ResolverTypeWrapper<Result>>, {}, MyContext, {}>'.
Type 'Promise<Result | Promise<Result> | {} | null>' is not assignable to type 'Result | Promise<Result> | Promise<Maybe<ResolverTypeWrapper<Result>>> | null'.
Type 'Promise<Result | Promise<Result> | {} | null>' is not assignable to type 'Promise<Result>'.
Type 'Result | Promise<Result> | {} | null' is not assignable to type 'Result'.
Type 'null' is not assignable to type 'Result'.
Environment:
- OS: Linux
@graphql-codegen/...
: 1.9.1- NodeJS: 12