Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add index signature to IResolvers and IDirectiveResolvers #1357

Merged
merged 2 commits into from
Feb 27, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure it won't mark all properties as never?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah looks suspicious

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can try it :)


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 interface IDirectiveResolvers<Result> = {
ardatan marked this conversation as resolved.
Show resolved Hide resolved
modify?: ModifyDirectiveResolver<Result>;
skip?: SkipDirectiveResolver<Result>;
include?: IncludeDirectiveResolver<Result>;
deprecated?: DeprecatedDirectiveResolver<Result>;
}
} & { [directiveName: string] : never };
`);
});

Expand Down