-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow custom resolver filenames using
filename_template
option
This is a squash commit of #1085, required to fix the broken tests and resolve merge conflicts.
- Loading branch information
1 parent
fbfdd41
commit ad675f0
Showing
8 changed files
with
120 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
schema: | ||
- "testdata/schema.graphql" | ||
|
||
exec: | ||
filename: testdata/singlefile/out/ignored.go | ||
model: | ||
filename: testdata/singlefile/out/generated.go | ||
resolver: | ||
type: CustomResolverType | ||
layout: follow-schema | ||
dir: testdata/filetemplate/out | ||
filename_template: "{name}.custom.go" | ||
|
||
models: | ||
Resolver: | ||
model: github.com/99designs/gqlgen/plugin/resolvergen/testdata/singlefile/out.Resolver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package customresolver | ||
|
||
import "context" | ||
|
||
type Resolver struct { | ||
} | ||
|
||
type QueryResolver interface { | ||
Resolver(ctx context.Context) (*Resolver, error) | ||
} | ||
|
||
type ResolverResolver interface { | ||
Name(ctx context.Context, obj *Resolver) (string, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package customresolver | ||
|
||
// This file will not be regenerated automatically. | ||
// | ||
// It serves as dependency injection for your app, add any dependencies you require here. | ||
|
||
type CustomResolverType struct{} |
41 changes: 41 additions & 0 deletions
41
plugin/resolvergen/testdata/filetemplate/out/schema.custom.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package customresolver | ||
|
||
// This file will be automatically regenerated based on the schema, any resolver implementations | ||
// will be copied through when generating and any unknown code will be moved to the end. | ||
|
||
import ( | ||
"context" | ||
|
||
customresolver "github.com/99designs/gqlgen/plugin/resolvergen/testdata/singlefile/out" | ||
) | ||
|
||
func (r *queryCustomResolverType) Resolver(ctx context.Context) (*customresolver.Resolver, error) { | ||
// CustomerResolverType.Resolver implementation | ||
return nil, nil | ||
} | ||
|
||
func (r *resolverCustomResolverType) Name(ctx context.Context, obj *customresolver.Resolver) (string, error) { | ||
// CustomerResolverType.Name implementation | ||
return "", nil | ||
} | ||
|
||
// Query returns customresolver.QueryResolver implementation. | ||
func (r *CustomResolverType) Query() customresolver.QueryResolver { return &queryCustomResolverType{r} } | ||
|
||
// Resolver returns customresolver.ResolverResolver implementation. | ||
func (r *CustomResolverType) Resolver() customresolver.ResolverResolver { | ||
return &resolverCustomResolverType{r} | ||
} | ||
|
||
type queryCustomResolverType struct{ *CustomResolverType } | ||
type resolverCustomResolverType struct{ *CustomResolverType } | ||
|
||
// !!! WARNING !!! | ||
// The code below was going to be deleted when updating resolvers. It has been copied here so you have | ||
// one last chance to move it out of harms way if you want. There are two reasons this happens: | ||
// - When renaming or deleting a resolver the old code will be put in here. You can safely delete | ||
// it when you're done. | ||
// - You have helper methods in this file. Move them out to keep these resolver files clean. | ||
func AUserHelperFunction() { | ||
// AUserHelperFunction implementation | ||
} |