diff --git a/packages/plugins/typescript-resolvers/src/root.handlebars b/packages/plugins/typescript-resolvers/src/root.handlebars index 56201d82987..c19703c5a78 100644 --- a/packages/plugins/typescript-resolvers/src/root.handlebars +++ b/packages/plugins/typescript-resolvers/src/root.handlebars @@ -66,7 +66,7 @@ export type DirectiveResolverFn = ( {{~> scalar}} {{/each}} -export interface IResolvers { +export type IResolvers = { {{#each types}} {{ convert name 'typeNames'}}{{#unless @root.config.strict}}?{{/unless}}: {{ convert name 'typeNames'}}Resolvers{{#unless @root.config.noNamespaces}}.Resolvers{{/unless}}; {{/each}} @@ -79,10 +79,10 @@ export interface IResolvers { {{#each scalars}} {{ convert name 'typeNames'}}{{#unless @root.config.strict}}?{{/unless}}: GraphQLScalarType; {{/each}} -} +} & { [typeName: string] : never }; -export interface IDirectiveResolvers { +export type IDirectiveResolvers = { {{#each definedDirectives}} {{ name }}{{#unless @root.config.strict}}?{{/unless}}: {{ convert name 'typeNames'}}DirectiveResolver; {{/each}} -} +} & { [directiveName: string] : never }; diff --git a/packages/plugins/typescript-resolvers/tests/typescript-resolvers.spec.ts b/packages/plugins/typescript-resolvers/tests/typescript-resolvers.spec.ts index 3a9f3c440cb..08a5cb90e23 100644 --- a/packages/plugins/typescript-resolvers/tests/typescript-resolvers.spec.ts +++ b/packages/plugins/typescript-resolvers/tests/typescript-resolvers.spec.ts @@ -1230,23 +1230,23 @@ describe('Resolvers', () => { ); expect(content).toBeSimilarStringTo(` - export interface IResolvers { + export type IResolvers = { Query?: QueryResolvers; Post?: PostResolvers; User?: UserResolvers; Node?: NodeResolvers; PostOrUser?: PostOrUserResolvers; Date?: GraphQLScalarType; - } + } & { [typeName: string] : never }; `); expect(content).toBeSimilarStringTo(` - export interface IDirectiveResolvers { + export type IDirectiveResolvers = { modify?: ModifyDirectiveResolver; skip?: SkipDirectiveResolver; include?: IncludeDirectiveResolver; deprecated?: DeprecatedDirectiveResolver; - } + } & { [directiveName: string] : never }; `); });