From 5055c9c38581c37ca0d56b1e286d5474893788ed Mon Sep 17 00:00:00 2001 From: ichikawashingo Date: Fri, 1 Nov 2024 17:57:30 +0900 Subject: [PATCH] replace all rc to opCtx --- .../federation/products/graph/generated.go | 2 +- _examples/fileupload/generated.go | 2 +- _examples/todo/generated.go | 8 ++++---- _examples/type-system-extension/generated.go | 2 +- codegen/generated!.gotpl | 20 +++++++++---------- graphql/handler/transport/http_get.go | 8 ++++---- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/_examples/federation/products/graph/generated.go b/_examples/federation/products/graph/generated.go index 0efac95a452..d65f535f954 100644 --- a/_examples/federation/products/graph/generated.go +++ b/_examples/federation/products/graph/generated.go @@ -94,7 +94,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { if first { first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data = ec._Query(ctx, rc.Operation.SelectionSet) + data = ec._Query(ctx, opCtx.Operation.SelectionSet) } else { if atomic.LoadInt32(&ec.pendingDeferred) > 0 { result := <-ec.deferredResults diff --git a/_examples/fileupload/generated.go b/_examples/fileupload/generated.go index d6bfcf19ec2..2a80448a360 100644 --- a/_examples/fileupload/generated.go +++ b/_examples/fileupload/generated.go @@ -228,7 +228,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { } first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data := ec._Mutation(ctx, rc.Operation.SelectionSet) + data := ec._Mutation(ctx, opCtx.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) diff --git a/_examples/todo/generated.go b/_examples/todo/generated.go index c9d95c2d302..0ff80352d40 100644 --- a/_examples/todo/generated.go +++ b/_examples/todo/generated.go @@ -186,8 +186,8 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { if first { first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data = ec._queryMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error) { - return ec._MyQuery(ctx, rc.Operation.SelectionSet), nil + data = ec._queryMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (interface{}, error) { + return ec._MyQuery(ctx, opCtx.Operation.SelectionSet), nil }) } else { if atomic.LoadInt32(&ec.pendingDeferred) > 0 { @@ -218,8 +218,8 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { } first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data := ec._mutationMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error) { - return ec._MyMutation(ctx, rc.Operation.SelectionSet), nil + data := ec._mutationMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (interface{}, error) { + return ec._MyMutation(ctx, opCtx.Operation.SelectionSet), nil }) var buf bytes.Buffer data.MarshalGQL(&buf) diff --git a/_examples/type-system-extension/generated.go b/_examples/type-system-extension/generated.go index 728a293c6c7..511aa235571 100644 --- a/_examples/type-system-extension/generated.go +++ b/_examples/type-system-extension/generated.go @@ -206,7 +206,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { } first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data := ec._MyMutation(ctx, rc.Operation.SelectionSet) + data := ec._MyMutation(ctx, opCtx.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) diff --git a/codegen/generated!.gotpl b/codegen/generated!.gotpl index 21b53b23abe..157fbcb1ed0 100644 --- a/codegen/generated!.gotpl +++ b/codegen/generated!.gotpl @@ -161,7 +161,7 @@ ) first := true - switch rc.Operation.Operation { + switch opCtx.Operation.Operation { {{- if .QueryRoot }} case ast.Query: return func(ctx context.Context) *graphql.Response { var response graphql.Response @@ -170,11 +170,11 @@ first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) {{ if .Directives.LocationDirectives "QUERY" -}} - data = ec._queryMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){ - return ec._{{.QueryRoot.Name}}(ctx, rc.Operation.SelectionSet), nil + data = ec._queryMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (interface{}, error){ + return ec._{{.QueryRoot.Name}}(ctx, opCtx.Operation.SelectionSet), nil }) {{- else -}} - data = ec._{{.QueryRoot.Name}}(ctx, rc.Operation.SelectionSet) + data = ec._{{.QueryRoot.Name}}(ctx, opCtx.Operation.SelectionSet) {{- end }} } else { if atomic.LoadInt32(&ec.pendingDeferred) > 0 { @@ -206,11 +206,11 @@ first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) {{ if .Directives.LocationDirectives "MUTATION" -}} - data := ec._mutationMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){ - return ec._{{.MutationRoot.Name}}(ctx, rc.Operation.SelectionSet), nil + data := ec._mutationMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (interface{}, error){ + return ec._{{.MutationRoot.Name}}(ctx, opCtx.Operation.SelectionSet), nil }) {{- else -}} - data := ec._{{.MutationRoot.Name}}(ctx, rc.Operation.SelectionSet) + data := ec._{{.MutationRoot.Name}}(ctx, opCtx.Operation.SelectionSet) {{- end }} var buf bytes.Buffer data.MarshalGQL(&buf) @@ -223,11 +223,11 @@ {{- if .SubscriptionRoot }} case ast.Subscription: {{ if .Directives.LocationDirectives "SUBSCRIPTION" -}} - next := ec._subscriptionMiddleware(ctx, rc.Operation, func(ctx context.Context) (interface{}, error){ - return ec._{{.SubscriptionRoot.Name}}(ctx, rc.Operation.SelectionSet),nil + next := ec._subscriptionMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (interface{}, error){ + return ec._{{.SubscriptionRoot.Name}}(ctx, opCtx.Operation.SelectionSet),nil }) {{- else -}} - next := ec._{{.SubscriptionRoot.Name}}(ctx, rc.Operation.SelectionSet) + next := ec._{{.SubscriptionRoot.Name}}(ctx, opCtx.Operation.SelectionSet) {{- end }} var buf bytes.Buffer diff --git a/graphql/handler/transport/http_get.go b/graphql/handler/transport/http_get.go index 470a0fbec29..09f1020d03c 100644 --- a/graphql/handler/transport/http_get.go +++ b/graphql/handler/transport/http_get.go @@ -66,21 +66,21 @@ func (h GET) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecut raw.ReadTime.End = graphql.Now() - rc, gqlError := exec.CreateOperationContext(r.Context(), raw) + opCtx, gqlError := exec.CreateOperationContext(r.Context(), raw) if gqlError != nil { w.WriteHeader(statusFor(gqlError)) - resp := exec.DispatchError(graphql.WithOperationContext(r.Context(), rc), gqlError) + resp := exec.DispatchError(graphql.WithOperationContext(r.Context(), opCtx), gqlError) writeJson(w, resp) return } - op := rc.Doc.Operations.ForName(rc.OperationName) + op := opCtx.Doc.Operations.ForName(opCtx.OperationName) if op.Operation != ast.Query { w.WriteHeader(http.StatusNotAcceptable) writeJsonError(w, "GET requests only allow query operations") return } - responses, ctx := exec.DispatchOperation(r.Context(), rc) + responses, ctx := exec.DispatchOperation(r.Context(), opCtx) writeJson(w, responses(ctx)) }