prisma-labs/graphqlgen

Add ability to disable generation of DelegatedParentResolver types

rynobax opened this issue · 1 comments

Description

I have some tests that directly call my resolver functions. Upgrading to any version past #429 causes Typescript to complain that it Cannot invoke an expression whose type lacks a call signature. It would be nice to be able to turn off the generation of DelegatedParentResolver signatures if you are not using them.

I would be happy to try to make a PR for this change, just want to get the go ahead first!

Additional context

Minimal reproduction case (note that for some reason you can call the resolver in the same file it is defined in, but when you import it in another file you will get the error)

// schema.graphql
type Query {
  foo: String!
}
// resolvers.ts
import { QueryResolvers } from './generated/graphqlgen';
export const fooResolver: QueryResolvers.FooResolver = () => 'Foo';
// test.ts
import { fooResolver } from './resolvers';
const fooResult = fooResolver(undefined, {}, null, null as any);
// Cannot invoke an expression whose type lacks a call signature.
// Type 'FooResolver' has no compatible call signatures. ts(2349)

Making DelegatedParentResolver types optional sounds like a good idea. Maybe they even should be disabled by default, because I think the majority of people using this library won't need them.