Skip to content

Commit

Permalink
Pass context to CollectFields instead of RequestContext
Browse files Browse the repository at this point in the history
Internally it can still get to RequestContext as required.
  • Loading branch information
Mathew Byrne committed Jul 23, 2018
1 parent c7ff320 commit a69071e
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 157 deletions.
2 changes: 1 addition & 1 deletion codegen/templates/data.go

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

6 changes: 2 additions & 4 deletions codegen/templates/object.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ var {{ $object.GQLType|lcFirst}}Implementors = {{$object.Implementors}}
// nolint: gocyclo, errcheck, gas, goconst
{{- if .Stream }}
func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler {
reqCtx := graphql.GetRequestContext(ctx)
fields := graphql.CollectFields(reqCtx, sel, {{$object.GQLType|lcFirst}}Implementors)
fields := graphql.CollectFields(ctx, sel, {{$object.GQLType|lcFirst}}Implementors)
ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{
Object: {{$object.GQLType|quote}},
})
Expand All @@ -26,8 +25,7 @@ func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.Se
}
{{- else }}
func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.FullName}} {{end}}) graphql.Marshaler {
reqCtx := graphql.GetRequestContext(ctx)
fields := graphql.CollectFields(reqCtx, sel, {{$object.GQLType|lcFirst}}Implementors)
fields := graphql.CollectFields(ctx, sel, {{$object.GQLType|lcFirst}}Implementors)
{{if $object.Root}}
ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{
Object: {{$object.GQLType|quote}},
Expand Down
33 changes: 11 additions & 22 deletions example/chat/generated.go

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

33 changes: 11 additions & 22 deletions example/dataloader/generated.go

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

Loading

0 comments on commit a69071e

Please sign in to comment.