Skip to content

Commit

Permalink
graphql/gqlgen: remove unnecessary convenience method
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Mar 4, 2020
1 parent fb86f7b commit 57dd8d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
18 changes: 0 additions & 18 deletions graphql/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,6 @@ func New(es graphql.ExecutableSchema) *Executor {
return e
}

// Exec returns a graphql response from the given params.
func (e *Executor) Exec(ctx context.Context, params *graphql.RawParams) *graphql.Response {
ctx = graphql.StartOperationTrace(ctx)
now := graphql.Now()
params.ReadTime = graphql.TraceTiming{
Start: now,
End: now,
}

rc, err := e.CreateOperationContext(ctx, params)
if err != nil {
return e.DispatchError(graphql.WithOperationContext(ctx, rc), err)
}

resp, ctx2 := e.DispatchOperation(ctx, rc)
return resp(ctx2)
}

func (e *Executor) CreateOperationContext(ctx context.Context, params *graphql.RawParams) (*graphql.OperationContext, gqlerror.List) {
rc := &graphql.OperationContext{
DisableIntrospection: true,
Expand Down
10 changes: 9 additions & 1 deletion graphql/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,16 @@ func TestErrorServer(t *testing.T) {
}

func query(exec *testexecutor.TestExecutor, op, q string) *graphql.Response {
return exec.Exec(context.Background(), &graphql.RawParams{
ctx := context.Background()
rc, err := exec.CreateOperationContext(ctx, &graphql.RawParams{
Query: q,
OperationName: op,
})

if err != nil {
return exec.DispatchError(graphql.WithOperationContext(ctx, rc), err)
}

resp, ctx2 := exec.DispatchOperation(ctx, rc)
return resp(ctx2)
}

0 comments on commit 57dd8d9

Please sign in to comment.