Skip to content

Commit

Permalink
Cleaning up extra return in federation generated code (#1713)
Browse files Browse the repository at this point in the history
In PR 1709, I introduced GetMany semantics for resolving federated entities.  But I left a couple of extra return statements in the generated code that are not necessary. So Im just cleaning those up here.

Also added `go:generate` in federation entity resolver tests to make it simpler to test.

To test:
```
go generate ./... && cd example/ && go generate ./... && cd ..
go test -race ./... && cd example && go test -race ./... && cd ..
```
  • Loading branch information
MiguelCastillo committed Nov 13, 2021
1 parent 402a225 commit af33b7c
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 23 deletions.
4 changes: 0 additions & 4 deletions example/federation/accounts/graph/generated/federation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions example/federation/products/graph/generated/federation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions example/federation/reviews/graph/generated/federation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions plugin/federation/federation.gotpl
Expand Up @@ -160,14 +160,13 @@ func (ec *executionContext) __resolve_entities(ctx context.Context, representati
{{- end -}}
list[idx[i]] = entity
}
return nil
{{ end }}
{{- end }}
{{ end }}
{{- end }}
default:
return errors.New("unknown type: "+typeName)
}

return nil
}

resolveEntityGroup := func(typeName string, reps []map[string]interface{}, idx []int) {
Expand Down Expand Up @@ -217,7 +216,5 @@ func (ec *executionContext) __resolve_entities(ctx context.Context, representati
g.Wait()
return list
}

return list
}
{{end}}
1 change: 1 addition & 0 deletions plugin/federation/federation_entityresolver_test.go
@@ -1,3 +1,4 @@
//go:generate go run ../../testdata/gqlgen.go -config testdata/entityresolver/gqlgen.yml
package federation

import (
Expand Down
4 changes: 2 additions & 2 deletions plugin/federation/readme.md
Expand Up @@ -9,7 +9,7 @@ There are several different tests. Some will process the configuration file dire

Running entity resolver tests.
1. Go to `plugin/federation`
2. Run the command `go run github.com/99designs/gqlgen --config testdata/entityresolver/gqlgen.yml`
2. Run the command `go generate`
3. Run the tests with `go test ./...`.

# Architecture
Expand All @@ -33,7 +33,7 @@ That allows the federation plugin to generate `GetMany` resolver function that c
From that entity type, the resolver function would be

```
func (r *entityResolver) FindManyMultiHellosByName(ctx context.Context, reps []*generated.EntityResolverfindManyMultiHellosByNameInput) ([]*generated.MultiHello, error) {
func (r *entityResolver) FindManyMultiHellosByName(ctx context.Context, reps []*generated.ManyMultiHellosByNameInput) ([]*generated.MultiHello, error) {
/// <Your code to resolve the list of items>
}
```

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit af33b7c

Please sign in to comment.