Skip to content

Commit

Permalink
replace all rc to opCtx
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ichikawa committed Nov 1, 2024
1 parent bd123a4 commit 5055c9c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion _examples/federation/products/graph/generated.go

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

2 changes: 1 addition & 1 deletion _examples/fileupload/generated.go

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

8 changes: 4 additions & 4 deletions _examples/todo/generated.go

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

2 changes: 1 addition & 1 deletion _examples/type-system-extension/generated.go

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

20 changes: 10 additions & 10 deletions codegen/generated!.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions graphql/handler/transport/http_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down

0 comments on commit 5055c9c

Please sign in to comment.