-
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.
Config option to preserve single file resolvers instead of always rew…
…riting (#3359) Signed-off-by: Steve Coffman <steve@khanacademy.org>
- Loading branch information
1 parent
b207ed5
commit b332879
Showing
11 changed files
with
193 additions
and
7 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
38 changes: 38 additions & 0 deletions
38
plugin/resolvergen/testdata/filetemplate/out/schema.custom.go.txt
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,38 @@ | ||
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. | ||
// Code generated by github.com/99designs/gqlgen | ||
|
||
import ( | ||
"context" | ||
|
||
customresolver "github.com/99designs/gqlgen/plugin/resolvergen/testdata/singlefile/out" | ||
) | ||
|
||
// Resolver is the resolver for the resolver field. | ||
func (r *queryCustomResolverType) Resolver(ctx context.Context) (*customresolver.Resolver, error) { | ||
// CustomerResolverType.Resolver implementation | ||
return nil, nil | ||
} | ||
|
||
// Name is the resolver for the name field. | ||
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 } | ||
|
||
func AUserHelperFunction() { | ||
// AUserHelperFunction implementation | ||
} |
38 changes: 38 additions & 0 deletions
38
plugin/resolvergen/testdata/followschema/out/schema.resolvers.go.txt
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,38 @@ | ||
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. | ||
// Code generated by github.com/99designs/gqlgen | ||
|
||
import ( | ||
"context" | ||
|
||
customresolver "github.com/99designs/gqlgen/plugin/resolvergen/testdata/singlefile/out" | ||
) | ||
|
||
// Resolver is the resolver for the resolver field. | ||
func (r *queryCustomResolverType) Resolver(ctx context.Context) (_ *customresolver.Resolver, err error) { | ||
// Named return values are supported. | ||
return | ||
} | ||
|
||
// Name is the resolver for the name field. | ||
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 } | ||
|
||
func AUserHelperFunction() { | ||
// AUserHelperFunction implementation | ||
} |
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
17 changes: 17 additions & 0 deletions
17
plugin/resolvergen/testdata/singlefile_preserve/gqlgen.yml
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,17 @@ | ||
schema: | ||
- "testdata/schema.graphql" | ||
|
||
exec: | ||
filename: testdata/singlefile_preserve/out/ignored.go | ||
model: | ||
filename: testdata/singlefile_preserve/out/generated.go | ||
resolver: | ||
filename: testdata/singlefile_preserve/out/resolver.go | ||
type: CustomResolverType | ||
preserve_resolver: true | ||
|
||
models: | ||
Resolver: | ||
model: github.com/99designs/gqlgen/plugin/resolvergen/testdata/singlefile_preserve/out.Resolver | ||
|
||
omit_gqlgen_version_in_file_notice: true |
13 changes: 13 additions & 0 deletions
13
plugin/resolvergen/testdata/singlefile_preserve/out/model.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,13 @@ | ||
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) | ||
} |
28 changes: 28 additions & 0 deletions
28
plugin/resolvergen/testdata/singlefile_preserve/out/resolver.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,28 @@ | ||
package customresolver | ||
|
||
// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
type CustomResolverType struct{} | ||
|
||
// Resolver is the resolver for the resolver field. | ||
func (r *queryCustomResolverType) Resolver(ctx context.Context) (*Resolver, error) { | ||
panic("not implemented") | ||
} | ||
|
||
// Name is the resolver for the name field. | ||
func (r *resolverCustomResolverType) Name(ctx context.Context, obj *Resolver) (string, error) { | ||
panic("not implemented") | ||
} | ||
|
||
// Query returns QueryResolver implementation. | ||
func (r *CustomResolverType) Query() QueryResolver { return &queryCustomResolverType{r} } | ||
|
||
// Resolver returns ResolverResolver implementation. | ||
func (r *CustomResolverType) Resolver() ResolverResolver { return &resolverCustomResolverType{r} } | ||
|
||
type queryCustomResolverType struct{ *CustomResolverType } | ||
type resolverCustomResolverType struct{ *CustomResolverType } |