From ebfde103e0ca294e8ce6ba131419344a1be67048 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Thu, 19 Jul 2018 17:53:05 +1000 Subject: [PATCH 1/6] Pass request context through to CollectFields --- codegen/templates/data.go | 2 +- codegen/templates/object.gotpl | 6 +++-- example/chat/generated.go | 33 ++++++++++++++++-------- example/dataloader/generated.go | 33 ++++++++++++++++-------- example/scalars/generated.go | 27 +++++++++++++------- example/selection/generated.go | 27 +++++++++++++------- example/starwars/generated.go | 45 ++++++++++++++++++++++----------- example/todo/generated.go | 27 +++++++++++++------- graphql/context.go | 4 +-- graphql/exec.go | 17 ++++++------- test/generated.go | 30 ++++++++++++++-------- 11 files changed, 163 insertions(+), 88 deletions(-) diff --git a/codegen/templates/data.go b/codegen/templates/data.go index c7d750d7a0..74e9a1a349 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\tfields := graphql.CollectFields(ec.Doc, sel, {{$object.GQLType|lcFirst}}Implementors, ec.Variables)\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(ec.Doc, sel, {{$object.GQLType|lcFirst}}Implementors, ec.Variables)\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\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", } diff --git a/codegen/templates/object.gotpl b/codegen/templates/object.gotpl index 31a563c195..f7efbaeb8a 100644 --- a/codegen/templates/object.gotpl +++ b/codegen/templates/object.gotpl @@ -5,7 +5,8 @@ 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 { - fields := graphql.CollectFields(ec.Doc, sel, {{$object.GQLType|lcFirst}}Implementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, {{$object.GQLType|lcFirst}}Implementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: {{$object.GQLType|quote}}, }) @@ -25,7 +26,8 @@ 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 { - fields := graphql.CollectFields(ec.Doc, sel, {{$object.GQLType|lcFirst}}Implementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, 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 a78511caf4..128f357f3a 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -139,7 +139,8 @@ var chatroomImplementors = []string{"Chatroom"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Chatroom(ctx context.Context, sel ast.SelectionSet, obj *Chatroom) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, chatroomImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, chatroomImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -195,7 +196,8 @@ var messageImplementors = []string{"Message"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet, obj *Message) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, messageImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, messageImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -268,7 +270,8 @@ var mutationImplementors = []string{"Mutation"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, mutationImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, mutationImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Mutation", @@ -347,7 +350,8 @@ var queryImplementors = []string{"Query"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, queryImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", @@ -461,7 +465,8 @@ var subscriptionImplementors = []string{"Subscription"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, subscriptionImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, subscriptionImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Subscription", }) @@ -511,7 +516,8 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __DirectiveImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -602,7 +608,8 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __EnumValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -675,7 +682,8 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __FieldImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -786,7 +794,8 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __InputValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -862,7 +871,8 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __SchemaImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -975,7 +985,8 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __TypeImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, 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 7695566c64..0c87bdf667 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -115,7 +115,8 @@ var addressImplementors = []string{"Address"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *Address) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, addressImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, addressImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -175,7 +176,8 @@ var customerImplementors = []string{"Customer"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, obj *Customer) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, customerImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, customerImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -298,7 +300,8 @@ var itemImplementors = []string{"Item"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj *Item) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, itemImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, itemImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -332,7 +335,8 @@ var orderImplementors = []string{"Order"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, obj *Order) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, orderImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, orderImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -433,7 +437,8 @@ var queryImplementors = []string{"Query"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, queryImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", @@ -621,7 +626,8 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __DirectiveImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -712,7 +718,8 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __EnumValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -785,7 +792,8 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __FieldImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -896,7 +904,8 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __InputValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -972,7 +981,8 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __SchemaImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1085,7 +1095,8 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __TypeImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, 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 c9c6314c80..8ae59ada77 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -109,7 +109,8 @@ var addressImplementors = []string{"Address"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *model.Address) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, addressImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, addressImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -159,7 +160,8 @@ var queryImplementors = []string{"Query"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, queryImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", @@ -334,7 +336,8 @@ var userImplementors = []string{"User"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, userImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, userImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -497,7 +500,8 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __DirectiveImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -588,7 +592,8 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __EnumValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -661,7 +666,8 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __FieldImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -772,7 +778,8 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __InputValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -848,7 +855,8 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __SchemaImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -961,7 +969,8 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __TypeImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, 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 e46fbd0c97..49c3a6d69c 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -85,7 +85,8 @@ var likeImplementors = []string{"Like", "Event"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj *Like) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, likeImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, likeImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -176,7 +177,8 @@ var postImplementors = []string{"Post", "Event"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj *Post) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, postImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, postImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -267,7 +269,8 @@ var queryImplementors = []string{"Query"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, queryImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", @@ -376,7 +379,8 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __DirectiveImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -467,7 +471,8 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __EnumValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -540,7 +545,8 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __FieldImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -651,7 +657,8 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __InputValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -727,7 +734,8 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __SchemaImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -840,7 +848,8 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __TypeImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, 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 fc0036b3a8..a0421a34b0 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -209,7 +209,8 @@ var droidImplementors = []string{"Droid", "Character"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, obj *Droid) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, droidImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, droidImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -395,7 +396,8 @@ var friendsConnectionImplementors = []string{"FriendsConnection"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.SelectionSet, obj *FriendsConnection) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, friendsConnectionImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, friendsConnectionImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -524,7 +526,8 @@ var friendsEdgeImplementors = []string{"FriendsEdge"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionSet, obj *FriendsEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, friendsEdgeImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, friendsEdgeImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -571,7 +574,8 @@ var humanImplementors = []string{"Human", "Character"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, obj *Human) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, humanImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, humanImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -831,7 +835,8 @@ var mutationImplementors = []string{"Mutation"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, mutationImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, mutationImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Mutation", @@ -903,7 +908,8 @@ var pageInfoImplementors = []string{"PageInfo"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *PageInfo) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, pageInfoImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, pageInfoImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -963,7 +969,8 @@ var queryImplementors = []string{"Query"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, queryImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", @@ -1383,7 +1390,8 @@ var reviewImplementors = []string{"Review"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, obj *Review) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, reviewImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, reviewImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1446,7 +1454,8 @@ var starshipImplementors = []string{"Starship"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, obj *Starship) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, starshipImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, starshipImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1576,7 +1585,8 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __DirectiveImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1667,7 +1677,8 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __EnumValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1740,7 +1751,8 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __FieldImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1851,7 +1863,8 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __InputValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1927,7 +1940,8 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __SchemaImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -2040,7 +2054,8 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __TypeImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, 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 142f9f7954..18af42a66e 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -123,7 +123,8 @@ var myMutationImplementors = []string{"MyMutation"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, myMutationImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, myMutationImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "MyMutation", @@ -229,7 +230,8 @@ var myQueryImplementors = []string{"MyQuery"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, myQueryImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, myQueryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "MyQuery", @@ -419,7 +421,8 @@ var todoImplementors = []string{"Todo"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, todoImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, todoImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -479,7 +482,8 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __DirectiveImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -570,7 +574,8 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __EnumValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -643,7 +648,8 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __FieldImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -754,7 +760,8 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __InputValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -830,7 +837,8 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __SchemaImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -943,7 +951,8 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __TypeImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __TypeImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { diff --git a/graphql/context.go b/graphql/context.go index adce8491c3..adb6553b29 100644 --- a/graphql/context.go +++ b/graphql/context.go @@ -114,9 +114,9 @@ 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) + reqCtx := GetRequestContext(ctx) resctx := GetResolverContext(ctx) - return CollectFields(reqctx.Doc, resctx.Field.Selections, satisfies, reqctx.Variables) + return CollectFields(reqCtx, 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 0610b397a5..fdf585ecdf 100644 --- a/graphql/exec.go +++ b/graphql/exec.go @@ -15,11 +15,11 @@ type ExecutableSchema interface { Subscription(ctx context.Context, op *ast.OperationDefinition) func() *Response } -func CollectFields(doc *ast.QueryDocument, selSet ast.SelectionSet, satisfies []string, variables map[string]interface{}) []CollectedField { - return collectFields(doc, selSet, satisfies, variables, map[string]bool{}) +func CollectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []string) []CollectedField { + return collectFields(reqCtx, selSet, satisfies, map[string]bool{}) } -func collectFields(doc *ast.QueryDocument, selSet ast.SelectionSet, satisfies []string, variables map[string]interface{}, visited map[string]bool) []CollectedField { +func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []string, visited map[string]bool) []CollectedField { var groupedFields []CollectedField for _, sel := range selSet { @@ -34,12 +34,12 @@ func collectFields(doc *ast.QueryDocument, selSet ast.SelectionSet, satisfies [] f.Args = map[string]interface{}{} for _, arg := range sel.Arguments { if arg.Value.Kind == ast.Variable { - if val, ok := variables[arg.Value.Raw]; ok { + if val, ok := reqCtx.Variables[arg.Value.Raw]; ok { f.Args[arg.Name] = val } } else { var err error - f.Args[arg.Name], err = arg.Value.Value(variables) + f.Args[arg.Name], err = arg.Value.Value(reqCtx.Variables) if err != nil { panic(err) } @@ -54,8 +54,7 @@ func collectFields(doc *ast.QueryDocument, selSet ast.SelectionSet, satisfies [] if !instanceOf(sel.TypeCondition, satisfies) { continue } - - for _, childField := range collectFields(doc, sel.SelectionSet, satisfies, variables, visited) { + for _, childField := range collectFields(reqCtx, sel.SelectionSet, satisfies, visited) { f := getOrCreateField(&groupedFields, childField.Name, func() CollectedField { return childField }) f.Selections = append(f.Selections, childField.Selections...) } @@ -67,7 +66,7 @@ func collectFields(doc *ast.QueryDocument, selSet ast.SelectionSet, satisfies [] } visited[fragmentName] = true - fragment := doc.Fragments.ForName(fragmentName) + fragment := reqCtx.Doc.Fragments.ForName(fragmentName) if fragment == nil { // should never happen, validator has already run panic(fmt.Errorf("missing fragment %s", fragmentName)) @@ -77,7 +76,7 @@ func collectFields(doc *ast.QueryDocument, selSet ast.SelectionSet, satisfies [] continue } - for _, childField := range collectFields(doc, fragment.SelectionSet, satisfies, variables, visited) { + for _, childField := range collectFields(reqCtx, fragment.SelectionSet, satisfies, visited) { f := getOrCreateField(&groupedFields, childField.Name, func() CollectedField { return childField }) f.Selections = append(f.Selections, childField.Selections...) } diff --git a/test/generated.go b/test/generated.go index 240b8961e0..acf50af564 100644 --- a/test/generated.go +++ b/test/generated.go @@ -135,7 +135,8 @@ var elementImplementors = []string{"Element"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, obj *models.Element) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, elementImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, elementImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -261,7 +262,8 @@ var queryImplementors = []string{"Query"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, queryImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", @@ -483,7 +485,8 @@ 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 { - fields := graphql.CollectFields(ec.Doc, sel, userImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, userImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -558,7 +561,8 @@ var viewerImplementors = []string{"Viewer"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Viewer(ctx context.Context, sel ast.SelectionSet, obj *models.Viewer) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, viewerImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, viewerImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -595,7 +599,8 @@ var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __DirectiveImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __DirectiveImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -686,7 +691,8 @@ var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __EnumValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __EnumValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -759,7 +765,8 @@ var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __FieldImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __FieldImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -870,7 +877,8 @@ var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __InputValueImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __InputValueImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -946,7 +954,8 @@ var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __SchemaImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __SchemaImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { @@ -1059,7 +1068,8 @@ var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ec.Doc, sel, __TypeImplementors, ec.Variables) + reqCtx := graphql.GetRequestContext(ctx) + fields := graphql.CollectFields(reqCtx, sel, __TypeImplementors) out := graphql.NewOrderedMap(len(fields)) for i, field := range fields { From ea0f821cc6c8e661f4b60f26aeec12ac90bcf3e0 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Fri, 20 Jul 2018 11:41:51 +1000 Subject: [PATCH 2/6] Add skip/include directive implementation This is a snowflake implementation for skip/include directives based on the graphql-js implementation. Skip takes precedence here. --- graphql/exec.go | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/graphql/exec.go b/graphql/exec.go index fdf585ecdf..faf154d81a 100644 --- a/graphql/exec.go +++ b/graphql/exec.go @@ -25,6 +25,9 @@ func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies [] for _, sel := range selSet { switch sel := sel.(type) { case *ast.Field: + if !shouldIncludeNode(sel.Directives, reqCtx.Variables) { + continue + } f := getOrCreateField(&groupedFields, sel.Alias, func() CollectedField { f := CollectedField{ Alias: sel.Alias, @@ -51,7 +54,7 @@ func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies [] f.Selections = append(f.Selections, sel.SelectionSet...) case *ast.InlineFragment: - if !instanceOf(sel.TypeCondition, satisfies) { + if !shouldIncludeNode(sel.Directives, reqCtx.Variables) || !instanceOf(sel.TypeCondition, satisfies) { continue } for _, childField := range collectFields(reqCtx, sel.SelectionSet, satisfies, visited) { @@ -60,6 +63,9 @@ func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies [] } case *ast.FragmentSpread: + if !shouldIncludeNode(sel.Directives, reqCtx.Variables) { + continue + } fragmentName := sel.Name if _, seen := visited[fragmentName]; seen { continue @@ -117,3 +123,31 @@ func getOrCreateField(c *[]CollectedField, name string, creator func() Collected *c = append(*c, f) return &(*c)[len(*c)-1] } + +func shouldIncludeNode(directives ast.DirectiveList, variables map[string]interface{}) bool { + if d := directives.ForName("skip"); d != nil { + return !resolveIfArgument(d, variables) + } + + if d := directives.ForName("include"); d != nil { + return resolveIfArgument(d, variables) + } + + return true +} + +func resolveIfArgument(d *ast.Directive, variables map[string]interface{}) bool { + arg := d.Arguments.ForName("if") + if arg == nil { + panic(fmt.Sprintf("%s: argument 'if' not defined", d.Name)) + } + value, err := arg.Value.Value(variables) + if err != nil { + panic(err) + } + ret, ok := value.(bool) + if !ok { + panic(fmt.Sprintf("%s: argument 'if' is not a boolean", d.Name)) + } + return ret +} From cbfae3d31bd8ee298103c65d83d9eef7272d44b6 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Fri, 20 Jul 2018 14:38:39 +1000 Subject: [PATCH 3/6] Add skip/include test cases Adds a set of test cases for skip and include directives to the todo example. Also now conforms to spec if both are included. --- example/todo/todo_test.go | 93 +++++++++++++++++++++++++++++++++++++++ graphql/exec.go | 8 ++-- 2 files changed, 98 insertions(+), 3 deletions(-) diff --git a/example/todo/todo_test.go b/example/todo/todo_test.go index a9bcbe42e1..6857397e7a 100644 --- a/example/todo/todo_test.go +++ b/example/todo/todo_test.go @@ -128,3 +128,96 @@ func TestTodo(t *testing.T) { require.Equal(t, "Completed todo", resp.CreateTodo.Text) }) } + +func TestSkipAndIncludeDirectives(t *testing.T) { + srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(New()))) + c := client.New(srv.URL) + + t.Run("skip on field", func(t *testing.T) { + var resp map[string]interface{} + c.MustPost(`{ todo(id: 1) @skip(if:true) { __typename } }`, &resp) + _, ok := resp["todo"] + require.False(t, ok) + }) + + t.Run("skip on variable", func(t *testing.T) { + q := `query Test($cond: Boolean!) { todo(id: 1) @skip(if: $cond) { __typename } }` + var resp map[string]interface{} + + c.MustPost(q, &resp, client.Var("cond", true)) + _, ok := resp["todo"] + require.False(t, ok) + + c.MustPost(q, &resp, client.Var("cond", false)) + _, ok = resp["todo"] + require.True(t, ok) + }) + + t.Run("skip on inline fragment", func(t *testing.T) { + var resp struct { + Todo struct { + Typename string `json:"__typename"` + } + } + c.MustPost(`{ todo(id: 1) { + ...@skip(if:true) { + __typename + } + } + }`, &resp) + require.Empty(t, resp.Todo.Typename) + }) + + t.Run("skip on fragment", func(t *testing.T) { + var resp struct { + Todo struct { + Typename string `json:"__typename"` + } + } + c.MustPost(` + { + todo(id: 1) { + ...todoFragment @skip(if:true) + } + } + fragment todoFragment on Todo { + __typename + } + `, &resp) + require.Empty(t, resp.Todo.Typename) + }) + + t.Run("include on field", func(t *testing.T) { + q := `query Test($cond: Boolean!) { todo(id: 1) @include(if: $cond) { __typename } }` + var resp map[string]interface{} + + c.MustPost(q, &resp, client.Var("cond", true)) + _, ok := resp["todo"] + require.True(t, ok) + + c.MustPost(q, &resp, client.Var("cond", false)) + _, ok = resp["todo"] + require.False(t, ok) + }) + + t.Run("both skip and include defined", func(t *testing.T) { + type TestCase struct { + Skip bool + Include bool + Expected bool + } + table := []TestCase{ + TestCase{Skip: true, Include: true, Expected: false}, + TestCase{Skip: true, Include: false, Expected: false}, + TestCase{Skip: false, Include: true, Expected: true}, + TestCase{Skip: false, Include: false, Expected: false}, + } + q := `query Test($skip: Boolean!, $include: Boolean!) { todo(id: 1) @skip(if: $skip) @include(if: $include) { __typename } }` + for _, tc := range table { + var resp map[string]interface{} + c.MustPost(q, &resp, client.Var("skip", tc.Skip), client.Var("include", tc.Include)) + _, ok := resp["todo"] + require.Equal(t, tc.Expected, ok) + } + }) +} diff --git a/graphql/exec.go b/graphql/exec.go index faf154d81a..bc057f222e 100644 --- a/graphql/exec.go +++ b/graphql/exec.go @@ -125,15 +125,17 @@ func getOrCreateField(c *[]CollectedField, name string, creator func() Collected } func shouldIncludeNode(directives ast.DirectiveList, variables map[string]interface{}) bool { + skip, include := false, true + if d := directives.ForName("skip"); d != nil { - return !resolveIfArgument(d, variables) + skip = resolveIfArgument(d, variables) } if d := directives.ForName("include"); d != nil { - return resolveIfArgument(d, variables) + include = resolveIfArgument(d, variables) } - return true + return !skip && include } func resolveIfArgument(d *ast.Directive, variables map[string]interface{}) bool { From ce17cd9034ff42a6881429ac198afb572e6950f2 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 23 Jul 2018 11:43:41 +1000 Subject: [PATCH 4/6] Add default value test case --- example/todo/todo_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/example/todo/todo_test.go b/example/todo/todo_test.go index 6857397e7a..e5c4fdddfe 100644 --- a/example/todo/todo_test.go +++ b/example/todo/todo_test.go @@ -220,4 +220,11 @@ func TestSkipAndIncludeDirectives(t *testing.T) { require.Equal(t, tc.Expected, ok) } }) + + t.Run("skip with default query argument", func(t *testing.T) { + var resp map[string]interface{} + c.MustPost(`query Test($skip: Boolean = true) { todo(id: 1) @skip(if: $skip) { __typename } }`, &resp) + _, ok := resp["todo"] + require.False(t, ok) + }) } From c7ff32086724ca8a1fd8bf437cc1f7417c47a619 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 23 Jul 2018 12:00:21 +1000 Subject: [PATCH 5/6] Update gqlparser version to include default resolution --- Gopkg.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index f3469a5762..cb992303c3 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -176,7 +176,7 @@ [[projects]] branch = "master" - digest = "1:c179e14665261880f034b2f18df18a1b280c9446299798b18329731bb70419c4" + digest = "1:a59dc1530d6a590c18eca216936bace5fefc6fb4af18fb5a1cb44a9c5e0c6bc5" name = "github.com/vektah/gqlparser" packages = [ ".", @@ -188,7 +188,7 @@ "validator/rules", ] pruneopts = "UT" - revision = "95a9b3840e65451c8205cece9278c55206e0bfe2" + revision = "8098ed8dcb1ed81bd39ac117a2fc33b08d5eaaf0" [[projects]] branch = "master" From a69071e3a59ae80bef327cbc9f823933d5ec4794 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 23 Jul 2018 13:45:00 +1000 Subject: [PATCH 6/6] Pass context to CollectFields instead of RequestContext Internally it can still get to RequestContext as required. --- codegen/templates/data.go | 2 +- codegen/templates/object.gotpl | 6 ++--- example/chat/generated.go | 33 ++++++++---------------- example/dataloader/generated.go | 33 ++++++++---------------- example/scalars/generated.go | 27 +++++++------------- example/selection/generated.go | 27 +++++++------------- example/starwars/generated.go | 45 +++++++++++---------------------- example/todo/generated.go | 27 +++++++------------- graphql/context.go | 3 +-- graphql/exec.go | 4 +-- test/generated.go | 30 ++++++++-------------- 11 files changed, 80 insertions(+), 157 deletions(-) diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 74e9a1a349..a11f4ac7a3 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 f7efbaeb8a..9535a65a6d 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 128f357f3a..d7c2aad0a6 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 0c87bdf667..a789bb8194 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 8ae59ada77..0b04eb9201 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 49c3a6d69c..ea3ec24a96 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 a0421a34b0..2f6fe16805 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 18af42a66e..b063374a3a 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 adb6553b29..4ffaf38f56 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 bc057f222e..11fa9c95f3 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 acf50af564..3611343234 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 {