From 8bc1f6ef638b575484969f93bf2aaadec85eeaa0 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Mon, 25 Feb 2019 14:29:51 -0500 Subject: [PATCH 1/2] [TypeScript Resolvers] Apollo Server resolvers types missmatch #1133 --- packages/plugins/typescript-resolvers/src/root.handlebars | 8 ++++---- .../tests/typescript-resolvers.spec.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) 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..e21e2ea9e46 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 interface IDirectiveResolvers = { modify?: ModifyDirectiveResolver; skip?: SkipDirectiveResolver; include?: IncludeDirectiveResolver; deprecated?: DeprecatedDirectiveResolver; - } + } & { [directiveName: string] : never }; `); }); From aee691bbb1f34aceab3df2657db33c555bddc283 Mon Sep 17 00:00:00 2001 From: Kamil Kisiela Date: Tue, 26 Feb 2019 11:20:03 -0500 Subject: [PATCH 2/2] Update packages/plugins/typescript-resolvers/tests/typescript-resolvers.spec.ts Co-Authored-By: ardatan <20847995+ardatan@users.noreply.github.com> --- .../typescript-resolvers/tests/typescript-resolvers.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugins/typescript-resolvers/tests/typescript-resolvers.spec.ts b/packages/plugins/typescript-resolvers/tests/typescript-resolvers.spec.ts index e21e2ea9e46..08a5cb90e23 100644 --- a/packages/plugins/typescript-resolvers/tests/typescript-resolvers.spec.ts +++ b/packages/plugins/typescript-resolvers/tests/typescript-resolvers.spec.ts @@ -1241,7 +1241,7 @@ describe('Resolvers', () => { `); expect(content).toBeSimilarStringTo(` - export interface IDirectiveResolvers = { + export type IDirectiveResolvers = { modify?: ModifyDirectiveResolver; skip?: SkipDirectiveResolver; include?: IncludeDirectiveResolver;