Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/bb_portal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ go_library(
importpath = "github.com/buildbarn/bb-portal/cmd/bb_portal",
visibility = ["//visibility:private"],
deps = [
"//ent/gen/ent",
"//ent/gen/ent/migrate",
"//ent/gen/ent/runtime",
"//internal/api/grpc/bes",
Expand Down
5 changes: 2 additions & 3 deletions cmd/bb_portal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/buildbarn/bb-portal/ent/gen/ent"
"github.com/buildbarn/bb-portal/ent/gen/ent/migrate"
"github.com/buildbarn/bb-portal/internal/api/grpc/bes"
"github.com/buildbarn/bb-portal/internal/api/http/bepuploader"
Expand Down Expand Up @@ -164,7 +163,7 @@ func newBuildEventStreamService(
}
dbAuthService := dbauthservice.NewDbAuthService(dbClient.Ent(), clock.SystemClock, instanceNameAuthorizer, time.Second*5)

err = addGraphqlHandler(configuration, besConfiguration, dbAuthService, dependenciesGroup, grpcClientFactory, router, dbClient.Ent(), tracerProvider)
err = addGraphqlHandler(configuration, besConfiguration, dbAuthService, dependenciesGroup, grpcClientFactory, router, dbClient, tracerProvider)
if err != nil {
return util.StatusWrap(err, "Failed to add GraphQL handler for BuildEventStreamService")
}
Expand Down Expand Up @@ -207,7 +206,7 @@ func addGraphqlHandler(
dependenciesGroup program.Group,
grpcClientFactory bb_grpc.ClientFactory,
router *mux.Router,
dbClient *ent.Client,
dbClient database.Client,
tracerProvider trace.TracerProvider,
) error {
srv := graphql.NewGraphqlHandler(dbClient, tracerProvider)
Expand Down
1 change: 1 addition & 0 deletions internal/graphql/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ go_library(
"//ent/gen/ent/invocationtarget",
"//ent/gen/ent/sourcecontrol",
"//ent/gen/ent/target",
"//internal/database",
"//internal/graphql/helpers",
"//internal/graphql/model",
"//pkg/uuidgql",
Expand Down
8 changes: 4 additions & 4 deletions internal/graphql/custom.resolvers.go

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

8 changes: 4 additions & 4 deletions internal/graphql/ent.resolvers.go

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

9 changes: 4 additions & 5 deletions internal/graphql/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package graphql

import (
"github.com/99designs/gqlgen/graphql"

"github.com/buildbarn/bb-portal/ent/gen/ent"
"github.com/buildbarn/bb-portal/internal/database"
)

// This file will not be regenerated automatically.
Expand All @@ -12,12 +11,12 @@ import (

// The Resolver Type for DI
type Resolver struct {
client *ent.Client
db database.Client
}

// NewSchema creates a graphql executable schema.
func NewSchema(client *ent.Client) graphql.ExecutableSchema {
func NewSchema(db database.Client) graphql.ExecutableSchema {
return NewExecutableSchema(Config{
Resolvers: &Resolver{client: client},
Resolvers: &Resolver{db: db},
})
}
6 changes: 2 additions & 4 deletions internal/graphql/server.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package graphql

import (
"entgo.io/contrib/entgql"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/extension"
"github.com/99designs/gqlgen/graphql/handler/transport"
"github.com/aereal/otelgqlgen"
"github.com/buildbarn/bb-portal/ent/gen/ent"
"github.com/buildbarn/bb-portal/internal/database"
"go.opentelemetry.io/otel/trace"
)

// NewGraphqlHandler creates a new GraphQL handler
func NewGraphqlHandler(dbClient *ent.Client, tracerProvider trace.TracerProvider) *handler.Server {
func NewGraphqlHandler(dbClient database.Client, tracerProvider trace.TracerProvider) *handler.Server {
srv := handler.New(NewSchema(dbClient))
srv.AddTransport(transport.POST{})
srv.Use(extension.Introspection{})
srv.Use(entgql.Transactioner{TxOpener: dbClient})
srv.Use(otelgqlgen.New(otelgqlgen.WithTracerProvider(tracerProvider)))
// A fixed complexity limit for incoming GraphQL queries.
// See https://gqlgen.com/master/reference/complexity/ for more details.
Expand Down
1 change: 0 additions & 1 deletion test/integrationtest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ go_test(
],
data = glob(["testdata/**"]) + ["//frontend/src/graphql:__generated__"],
deps = [
"//ent/gen/ent",
"//ent/gen/ent/runtime",
"//internal/api/http/bepuploader",
"//internal/database",
Expand Down
2 changes: 1 addition & 1 deletion test/integrationtest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func runTestCase(t *testing.T, queryRegistry *testkit.QueryRegistry, testCase te
})
}

graphqlServer := startGraphqlHTTPServer(t, db.Ent())
graphqlServer := startGraphqlHTTPServer(t, db)

runGraphqlTestCases(ctx, t, graphqlServer.URL, queryRegistry, testCase)
}
Expand Down
5 changes: 2 additions & 3 deletions test/integrationtest/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"testing"

gqlgen "github.com/99designs/gqlgen/graphql"
"github.com/buildbarn/bb-portal/ent/gen/ent"
"github.com/buildbarn/bb-portal/internal/api/http/bepuploader"
"github.com/buildbarn/bb-portal/internal/database"
"github.com/buildbarn/bb-portal/internal/database/dbauthservice"
Expand Down Expand Up @@ -50,8 +49,8 @@ func setupTestBepUploader(t *testing.T, db database.Client, testCase testCase) *
return bepUploader
}

func startGraphqlHTTPServer(t *testing.T, client *ent.Client) *httptest.Server {
srv := graphql.NewGraphqlHandler(client, trace.NewNoopTracerProvider())
func startGraphqlHTTPServer(t *testing.T, db database.Client) *httptest.Server {
srv := graphql.NewGraphqlHandler(db, trace.NewNoopTracerProvider())

// Bypass DB auth service for integration tests.
srv.AroundOperations(func(ctx context.Context, next gqlgen.OperationHandler) gqlgen.ResponseHandler {
Expand Down
Loading