diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 74e9a1a3497..a11f4ac7a32 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -7,5 +7,5 @@ var data = map[string]string{ "input.gotpl": "\t{{- if .IsMarshaled }}\n\tfunc Unmarshal{{ .GQLType }}(v interface{}) ({{.FullName}}, error) {\n\t\tvar it {{.FullName}}\n\t\tvar asMap = v.(map[string]interface{})\n\t\t{{ range $field := .Fields}}\n\t\t\t{{- if $field.Default}}\n\t\t\t\tif _, present := asMap[{{$field.GQLName|quote}}] ; !present {\n\t\t\t\t\tasMap[{{$field.GQLName|quote}}] = {{ $field.Default | dump }}\n\t\t\t\t}\n\t\t\t{{- end}}\n\t\t{{- end }}\n\n\t\tfor k, v := range asMap {\n\t\t\tswitch k {\n\t\t\t{{- range $field := .Fields }}\n\t\t\tcase {{$field.GQLName|quote}}:\n\t\t\t\tvar err error\n\t\t\t\t{{ $field.Unmarshal (print \"it.\" $field.GoVarName) \"v\" }}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn it, err\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\t}\n\t\t}\n\n\t\treturn it, nil\n\t}\n\t{{- end }}\n", "interface.gotpl": "{{- $interface := . }}\n\nfunc (ec *executionContext) _{{$interface.GQLType}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.FullName}}) graphql.Marshaler {\n\tswitch obj := (*obj).(type) {\n\tcase nil:\n\t\treturn graphql.Null\n\t{{- range $implementor := $interface.Implementors }}\n\t\t{{- if $implementor.ValueReceiver }}\n\t\t\tcase {{$implementor.FullName}}:\n\t\t\t\treturn ec._{{$implementor.GQLType}}(ctx, sel, &obj)\n\t\t{{- end}}\n\t\tcase *{{$implementor.FullName}}:\n\t\t\treturn ec._{{$implementor.GQLType}}(ctx, sel, obj)\n\t{{- end }}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"unexpected type %T\", obj))\n\t}\n}\n", "models.gotpl": "// Code generated by github.com/vektah/gqlgen, DO NOT EDIT.\n\npackage {{ .PackageName }}\n\nimport (\n{{- range $import := .Imports }}\n\t{{- $import.Write }}\n{{ end }}\n)\n\n{{ range $model := .Models }}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- if $field.GoVarName }}\n\t\t\t\t\t{{ $field.GoVarName }} {{$field.Signature}} `json:\"{{$field.GQLName}}\"`\n\t\t\t\t{{- else }}\n\t\t\t\t\t{{ $field.GoFKName }} {{$field.GoFKType}}\n\t\t\t\t{{- end }}\n\t\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\ttype {{.GoType}} string\n\tconst (\n\t{{ range $value := .Values -}}\n\t\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t\t{{$enum.GoType}}{{ .Name|toCamel }} {{$enum.GoType}} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tfunc (e {{.GoType}}) IsValid() bool {\n\t\tswitch e {\n\t\tcase {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.GoType }}{{ $element.Name|toCamel }}{{end}}:\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tfunc (e {{.GoType}}) String() string {\n\t\treturn string(e)\n\t}\n\n\tfunc (e *{{.GoType}}) UnmarshalGQL(v interface{}) error {\n\t\tstr, ok := v.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"enums must be strings\")\n\t\t}\n\n\t\t*e = {{.GoType}}(str)\n\t\tif !e.IsValid() {\n\t\t\treturn fmt.Errorf(\"%s is not a valid {{.GQLType}}\", str)\n\t\t}\n\t\treturn nil\n\t}\n\n\tfunc (e {{.GoType}}) MarshalGQL(w io.Writer) {\n\t\tfmt.Fprint(w, strconv.Quote(e.String()))\n\t}\n\n{{- end }}\n", - "object.gotpl": "{{ $object := . }}\n\nvar {{ $object.GQLType|lcFirst}}Implementors = {{$object.Implementors}}\n\n// nolint: gocyclo, errcheck, gas, goconst\n{{- if .Stream }}\nfunc (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler {\n\treqCtx := graphql.GetRequestContext(ctx)\n\tfields := graphql.CollectFields(reqCtx, sel, {{$object.GQLType|lcFirst}}Implementors)\n\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\tObject: {{$object.GQLType|quote}},\n\t})\n\tif len(fields) != 1 {\n\t\tec.Errorf(ctx, \"must subscribe to exactly one stream\")\n\t\treturn nil\n\t}\n\n\tswitch fields[0].Name {\n\t{{- range $field := $object.Fields }}\n\tcase \"{{$field.GQLName}}\":\n\t\treturn ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, fields[0])\n\t{{- end }}\n\tdefault:\n\t\tpanic(\"unknown field \" + strconv.Quote(fields[0].Name))\n\t}\n}\n{{- else }}\nfunc (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.FullName}} {{end}}) graphql.Marshaler {\n\treqCtx := graphql.GetRequestContext(ctx)\n\tfields := graphql.CollectFields(reqCtx, sel, {{$object.GQLType|lcFirst}}Implementors)\n\t{{if $object.Root}}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t})\n\t{{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString({{$object.GQLType|quote}})\n\t\t{{- range $field := $object.Fields }}\n\t\tcase \"{{$field.GQLName}}\":\n\t\t\tout.Values[i] = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t{{- end }}\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\n\treturn out\n}\n{{- end }}\n", + "object.gotpl": "{{ $object := . }}\n\nvar {{ $object.GQLType|lcFirst}}Implementors = {{$object.Implementors}}\n\n// nolint: gocyclo, errcheck, gas, goconst\n{{- if .Stream }}\nfunc (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.GQLType|lcFirst}}Implementors)\n\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\tObject: {{$object.GQLType|quote}},\n\t})\n\tif len(fields) != 1 {\n\t\tec.Errorf(ctx, \"must subscribe to exactly one stream\")\n\t\treturn nil\n\t}\n\n\tswitch fields[0].Name {\n\t{{- range $field := $object.Fields }}\n\tcase \"{{$field.GQLName}}\":\n\t\treturn ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, fields[0])\n\t{{- end }}\n\tdefault:\n\t\tpanic(\"unknown field \" + strconv.Quote(fields[0].Name))\n\t}\n}\n{{- else }}\nfunc (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.FullName}} {{end}}) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.GQLType|lcFirst}}Implementors)\n\t{{if $object.Root}}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t})\n\t{{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString({{$object.GQLType|quote}})\n\t\t{{- range $field := $object.Fields }}\n\t\tcase \"{{$field.GQLName}}\":\n\t\t\tout.Values[i] = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t{{- end }}\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\n\treturn out\n}\n{{- end }}\n", } diff --git a/codegen/templates/object.gotpl b/codegen/templates/object.gotpl index f7efbaeb8a4..9535a65a6d6 100644 --- a/codegen/templates/object.gotpl +++ b/codegen/templates/object.gotpl @@ -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}}, }) @@ -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}}, diff --git a/example/chat/generated.go b/example/chat/generated.go index 128f357f3ae..d7c2aad0a69 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -139,8 +139,7 @@ var chatroomImplementors = []string{"Chatroom"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Chatroom(ctx context.Context, sel ast.SelectionSet, obj *Chatroom) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, chatroomImplementors) + fields := graphql.CollectFields(ctx, sel, chatroomImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -196,8 +195,7 @@ var messageImplementors = []string{"Message"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet, obj *Message) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, messageImplementors) + fields := graphql.CollectFields(ctx, sel, messageImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -270,8 +268,7 @@ var mutationImplementors = []string{"Mutation"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, mutationImplementors) + fields := graphql.CollectFields(ctx, sel, mutationImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Mutation", @@ -350,8 +347,7 @@ var queryImplementors = []string{"Query"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, queryImplementors) + fields := graphql.CollectFields(ctx, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", @@ -465,8 +461,7 @@ var subscriptionImplementors = []string{"Subscription"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, subscriptionImplementors) + fields := graphql.CollectFields(ctx, sel, subscriptionImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Subscription", }) @@ -516,8 +511,7 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -608,8 +602,7 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -682,8 +675,7 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -794,8 +786,7 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -871,8 +862,7 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -985,8 +975,7 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __TypeImplementors) + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 0c87bdf6673..a789bb81947 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -115,8 +115,7 @@ var addressImplementors = []string{"Address"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *Address) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, addressImplementors) + fields := graphql.CollectFields(ctx, sel, addressImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -176,8 +175,7 @@ var customerImplementors = []string{"Customer"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, obj *Customer) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, customerImplementors) + fields := graphql.CollectFields(ctx, sel, customerImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -300,8 +298,7 @@ var itemImplementors = []string{"Item"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj *Item) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, itemImplementors) + fields := graphql.CollectFields(ctx, sel, itemImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -335,8 +332,7 @@ var orderImplementors = []string{"Order"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, obj *Order) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, orderImplementors) + fields := graphql.CollectFields(ctx, sel, orderImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -437,8 +433,7 @@ var queryImplementors = []string{"Query"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, queryImplementors) + fields := graphql.CollectFields(ctx, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", @@ -626,8 +621,7 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -718,8 +712,7 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -792,8 +785,7 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -904,8 +896,7 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -981,8 +972,7 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1095,8 +1085,7 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __TypeImplementors) + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 8ae59ada777..0b04eb92016 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -109,8 +109,7 @@ var addressImplementors = []string{"Address"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *model.Address) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, addressImplementors) + fields := graphql.CollectFields(ctx, sel, addressImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -160,8 +159,7 @@ var queryImplementors = []string{"Query"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, queryImplementors) + fields := graphql.CollectFields(ctx, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", @@ -336,8 +334,7 @@ var userImplementors = []string{"User"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, userImplementors) + fields := graphql.CollectFields(ctx, sel, userImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -500,8 +497,7 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -592,8 +588,7 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -666,8 +661,7 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -778,8 +772,7 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -855,8 +848,7 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -969,8 +961,7 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __TypeImplementors) + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { diff --git a/example/selection/generated.go b/example/selection/generated.go index 49c3a6d69c8..ea3ec24a96a 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -85,8 +85,7 @@ var likeImplementors = []string{"Like", "Event"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj *Like) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, likeImplementors) + fields := graphql.CollectFields(ctx, sel, likeImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -177,8 +176,7 @@ var postImplementors = []string{"Post", "Event"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj *Post) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, postImplementors) + fields := graphql.CollectFields(ctx, sel, postImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -269,8 +267,7 @@ var queryImplementors = []string{"Query"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, queryImplementors) + fields := graphql.CollectFields(ctx, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", @@ -379,8 +376,7 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -471,8 +467,7 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -545,8 +540,7 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -657,8 +651,7 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -734,8 +727,7 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -848,8 +840,7 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __TypeImplementors) + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { diff --git a/example/starwars/generated.go b/example/starwars/generated.go index a0421a34b0c..2f6fe168050 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -209,8 +209,7 @@ var droidImplementors = []string{"Droid", "Character"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, obj *Droid) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, droidImplementors) + fields := graphql.CollectFields(ctx, sel, droidImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -396,8 +395,7 @@ var friendsConnectionImplementors = []string{"FriendsConnection"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.SelectionSet, obj *FriendsConnection) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, friendsConnectionImplementors) + fields := graphql.CollectFields(ctx, sel, friendsConnectionImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -526,8 +524,7 @@ var friendsEdgeImplementors = []string{"FriendsEdge"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionSet, obj *FriendsEdge) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, friendsEdgeImplementors) + fields := graphql.CollectFields(ctx, sel, friendsEdgeImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -574,8 +571,7 @@ var humanImplementors = []string{"Human", "Character"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, obj *Human) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, humanImplementors) + fields := graphql.CollectFields(ctx, sel, humanImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -835,8 +831,7 @@ var mutationImplementors = []string{"Mutation"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, mutationImplementors) + fields := graphql.CollectFields(ctx, sel, mutationImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Mutation", @@ -908,8 +903,7 @@ var pageInfoImplementors = []string{"PageInfo"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *PageInfo) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, pageInfoImplementors) + fields := graphql.CollectFields(ctx, sel, pageInfoImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -969,8 +963,7 @@ var queryImplementors = []string{"Query"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, queryImplementors) + fields := graphql.CollectFields(ctx, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", @@ -1390,8 +1383,7 @@ var reviewImplementors = []string{"Review"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, obj *Review) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, reviewImplementors) + fields := graphql.CollectFields(ctx, sel, reviewImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1454,8 +1446,7 @@ var starshipImplementors = []string{"Starship"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, obj *Starship) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, starshipImplementors) + fields := graphql.CollectFields(ctx, sel, starshipImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1585,8 +1576,7 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1677,8 +1667,7 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1751,8 +1740,7 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1863,8 +1851,7 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1940,8 +1927,7 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -2054,8 +2040,7 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __TypeImplementors) + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { diff --git a/example/todo/generated.go b/example/todo/generated.go index 18af42a66ea..b063374a3a6 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -123,8 +123,7 @@ var myMutationImplementors = []string{"MyMutation"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, myMutationImplementors) + fields := graphql.CollectFields(ctx, sel, myMutationImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "MyMutation", @@ -230,8 +229,7 @@ var myQueryImplementors = []string{"MyQuery"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, myQueryImplementors) + fields := graphql.CollectFields(ctx, sel, myQueryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "MyQuery", @@ -421,8 +419,7 @@ var todoImplementors = []string{"Todo"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, todoImplementors) + fields := graphql.CollectFields(ctx, sel, todoImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -482,8 +479,7 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -574,8 +570,7 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -648,8 +643,7 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -760,8 +754,7 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -837,8 +830,7 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -951,8 +943,7 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __TypeImplementors) + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { diff --git a/graphql/context.go b/graphql/context.go index adb6553b299..4ffaf38f568 100644 --- a/graphql/context.go +++ b/graphql/context.go @@ -114,9 +114,8 @@ func WithResolverContext(ctx context.Context, rc *ResolverContext) context.Conte // This is just a convenient wrapper method for CollectFields func CollectFieldsCtx(ctx context.Context, satisfies []string) []CollectedField { - reqCtx := GetRequestContext(ctx) resctx := GetResolverContext(ctx) - return CollectFields(reqCtx, resctx.Field.Selections, satisfies) + return CollectFields(ctx, resctx.Field.Selections, satisfies) } // Errorf sends an error string to the client, passing it through the formatter. diff --git a/graphql/exec.go b/graphql/exec.go index bc057f222e2..11fa9c95f33 100644 --- a/graphql/exec.go +++ b/graphql/exec.go @@ -15,8 +15,8 @@ type ExecutableSchema interface { Subscription(ctx context.Context, op *ast.OperationDefinition) func() *Response } -func CollectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []string) []CollectedField { - return collectFields(reqCtx, selSet, satisfies, map[string]bool{}) +func CollectFields(ctx context.Context, selSet ast.SelectionSet, satisfies []string) []CollectedField { + return collectFields(GetRequestContext(ctx), selSet, satisfies, map[string]bool{}) } func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []string, visited map[string]bool) []CollectedField { diff --git a/test/generated.go b/test/generated.go index acf50af564a..36113432341 100644 --- a/test/generated.go +++ b/test/generated.go @@ -135,8 +135,7 @@ var elementImplementors = []string{"Element"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, obj *models.Element) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, elementImplementors) + fields := graphql.CollectFields(ctx, sel, elementImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -262,8 +261,7 @@ var queryImplementors = []string{"Query"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, queryImplementors) + fields := graphql.CollectFields(ctx, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", @@ -485,8 +483,7 @@ var userImplementors = []string{"User"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *remote_api.User) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, userImplementors) + fields := graphql.CollectFields(ctx, sel, userImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -561,8 +558,7 @@ var viewerImplementors = []string{"Viewer"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Viewer(ctx context.Context, sel ast.SelectionSet, obj *models.Viewer) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, viewerImplementors) + fields := graphql.CollectFields(ctx, sel, viewerImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -599,8 +595,7 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -691,8 +686,7 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -765,8 +759,7 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -877,8 +870,7 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -954,8 +946,7 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1068,8 +1059,7 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - reqCtx := graphql.GetRequestContext(ctx) - fields := graphql.CollectFields(reqCtx, sel, __TypeImplementors) + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields {