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

resolvergen: use the resolver type as base name for dependent types #728

Commits on Jun 15, 2019

  1. resolvergen: use the resolver type as base name for dependent types

    The template was outputing invalid code since the resolver type was
    not used in places like the embedding at {query,mutation}Resolver.
    
    This change also ensures that objects like {query,mutation}Resolver
    also use the user provided type name as suffix.
    
    Here's the resulting diff on the code generation with `type:
    GeneratedResolver` in the resolver config:
    
    ```
    diff -u resolver.go resolvernew.go
    --- resolver.go 2019-05-26 20:04:15.361969755 -0300
    +++ resolvernew.go      2019-05-26 20:04:54.170737786 -0300
    @@ -7,20 +7,20 @@
     type GeneratedResolver struct{}
    
     func (r *GeneratedResolver) Mutation() MutationResolver {
    -       return &mutationResolver{r}
    +       return &mutationGeneratedResolver{r}
     }
     func (r *GeneratedResolver) Query() QueryResolver {
    -       return &queryResolver{r}
    +       return &queryGeneratedResolver{r}
     }
    
    -type mutationResolver struct{ *Resolver }
    +type mutationGeneratedResolver struct{ *GeneratedResolver }
    
    -func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) {
    +func (r *mutationGeneratedResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) {
            panic("not implemented")
     }
    
    -type queryResolver struct{ *Resolver }
    +type queryGeneratedResolver struct{ *GeneratedResolver }
    
    -func (r *queryResolver) Todos(ctx context.Context) ([]*Todo, error) {
    +func (r *queryGeneratedResolver) Todos(ctx context.Context) ([]*Todo, error) {
            panic("not implemented")
     }
    ```
    fgallina committed Jun 15, 2019
    Configuration menu
    Copy the full SHA
    c5acbea View commit details
    Browse the repository at this point in the history