Skip to content

Commit

Permalink
Merge pull request #1357 from dotansimha/fix/iresolvers
Browse files Browse the repository at this point in the history
Add index signature to IResolvers and IDirectiveResolvers
  • Loading branch information
dotansimha authored Feb 27, 2019
2 parents 9ad67a0 + aee691b commit b0c24ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/plugins/typescript-resolvers/src/root.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export type DirectiveResolverFn<TResult, TArgs = {}, TContext = {}> = (
{{~> scalar}}
{{/each}}

export interface IResolvers<TContext = {{{ getContext }}}> {
export type IResolvers<TContext = {{{ getContext }}}> = {
{{#each types}}
{{ convert name 'typeNames'}}{{#unless @root.config.strict}}?{{/unless}}: {{ convert name 'typeNames'}}Resolvers{{#unless @root.config.noNamespaces}}.Resolvers{{/unless}}<TContext>;
{{/each}}
Expand All @@ -79,10 +79,10 @@ export interface IResolvers<TContext = {{{ getContext }}}> {
{{#each scalars}}
{{ convert name 'typeNames'}}{{#unless @root.config.strict}}?{{/unless}}: GraphQLScalarType;
{{/each}}
}
} & { [typeName: string] : never };

export interface IDirectiveResolvers<Result> {
export type IDirectiveResolvers<Result> = {
{{#each definedDirectives}}
{{ name }}{{#unless @root.config.strict}}?{{/unless}}: {{ convert name 'typeNames'}}DirectiveResolver<Result>;
{{/each}}
}
} & { [directiveName: string] : never };
Original file line number Diff line number Diff line change
Expand Up @@ -1230,23 +1230,23 @@ describe('Resolvers', () => {
);

expect(content).toBeSimilarStringTo(`
export interface IResolvers<TContext = {}> {
export type IResolvers<TContext = {}> = {
Query?: QueryResolvers<TContext>;
Post?: PostResolvers<TContext>;
User?: UserResolvers<TContext>;
Node?: NodeResolvers;
PostOrUser?: PostOrUserResolvers;
Date?: GraphQLScalarType;
}
} & { [typeName: string] : never };
`);

expect(content).toBeSimilarStringTo(`
export interface IDirectiveResolvers<Result> {
export type IDirectiveResolvers<Result> = {
modify?: ModifyDirectiveResolver<Result>;
skip?: SkipDirectiveResolver<Result>;
include?: IncludeDirectiveResolver<Result>;
deprecated?: DeprecatedDirectiveResolver<Result>;
}
} & { [directiveName: string] : never };
`);
});

Expand Down

0 comments on commit b0c24ea

Please sign in to comment.