Skip to content

Commit

Permalink
shadow context to ensure scoped context use
Browse files Browse the repository at this point in the history
  • Loading branch information
vektah committed Jul 26, 2020
1 parent 7f691f9 commit 54f457a
Show file tree
Hide file tree
Showing 17 changed files with 554 additions and 554 deletions.
8 changes: 4 additions & 4 deletions codegen/args.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ func (ec *executionContext) {{ $name }}(ctx context.Context, rawArgs map[string]
{{- range $i, $arg := . }}
var arg{{$i}} {{ $arg.TypeReference.GO | ref}}
if tmp, ok := rawArgs[{{$arg.Name|quote}}]; ok {
childCtx := graphql.WithFieldInputContext(ctx, graphql.NewFieldInputWithField({{$arg.Name|quote}}))
ctx := graphql.WithFieldInputContext(ctx, graphql.NewFieldInputWithField({{$arg.Name|quote}}))
{{- if $arg.ImplDirectives }}
directive0 := func(ctx context.Context) (interface{}, error) { return ec.{{ $arg.TypeReference.UnmarshalFunc }}(childCtx, tmp) }
directive0 := func(ctx context.Context) (interface{}, error) { return ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, tmp) }
{{ template "implDirectives" $arg }}
tmp, err = directive{{$arg.ImplDirectives|len}}(childCtx)
tmp, err = directive{{$arg.ImplDirectives|len}}(ctx)
if err != nil {
return nil, err
}
Expand All @@ -23,7 +23,7 @@ func (ec *executionContext) {{ $name }}(ctx context.Context, rawArgs map[string]
return nil, fmt.Errorf(`unexpected type %T from directive, should be {{ $arg.TypeReference.GO }}`, tmp)
}
{{- else }}
arg{{$i}}, err = ec.{{ $arg.TypeReference.UnmarshalFunc }}(childCtx, tmp)
arg{{$i}}, err = ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, tmp)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions codegen/input.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
case {{$field.Name|quote}}:
var err error

childCtx := graphql.WithFieldInputContext(ctx, graphql.NewFieldInputWithField({{$field.Name|quote}}))
ctx := graphql.WithFieldInputContext(ctx, graphql.NewFieldInputWithField({{$field.Name|quote}}))
{{- if $field.ImplDirectives }}
directive0 := func(ctx context.Context) (interface{}, error) { return ec.{{ $field.TypeReference.UnmarshalFunc }}(childCtx, v) }
directive0 := func(ctx context.Context) (interface{}, error) { return ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v) }
{{ template "implDirectives" $field }}
tmp, err := directive{{$field.ImplDirectives|len}}(childCtx)
tmp, err := directive{{$field.ImplDirectives|len}}(ctx)
if err != nil {
return it, err
}
Expand All @@ -35,7 +35,7 @@
return it, fmt.Errorf(`unexpected type %T from directive, should be {{ $field.TypeReference.GO }}`, tmp)
}
{{- else }}
it.{{$field.GoFieldName}}, err = ec.{{ $field.TypeReference.UnmarshalFunc }}(childCtx, v)
it.{{$field.GoFieldName}}, err = ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v)
if err != nil {
return it, err
}
Expand Down
500 changes: 250 additions & 250 deletions codegen/testserver/generated.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions codegen/type.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
var err error
res := make([]{{$type.GO.Elem | ref}}, len(vSlice))
for i := range vSlice {
nctx := graphql.WithFieldInputContext(ctx, graphql.NewFieldInputWithIndex(i))
res[i], err = ec.{{ $type.Elem.UnmarshalFunc }}(nctx, vSlice[i])
ctx := graphql.WithFieldInputContext(ctx, graphql.NewFieldInputWithIndex(i))
res[i], err = ec.{{ $type.Elem.UnmarshalFunc }}(ctx, vSlice[i])
if err != nil {
return nil, graphql.WrapErrorWithInputPath(nctx, err)
return nil, graphql.WrapErrorWithInputPath(ctx, err)
}
}
return res, nil
Expand Down
42 changes: 21 additions & 21 deletions example/chat/generated.go

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

36 changes: 18 additions & 18 deletions example/config/generated.go

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

38 changes: 19 additions & 19 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 54f457a

Please sign in to comment.