Skip to content

Commit

Permalink
Merge pull request #149 from iota-uz/modify_executor
Browse files Browse the repository at this point in the history
allow to modify graphql executor
  • Loading branch information
diyor28 authored Feb 24, 2025
2 parents 64e752a + 3b01b96 commit 5464f41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion modules/core/presentation/controllers/graphql_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ func (g *GraphQLController) Register(r *mux.Router) {
router.Handle("/query", srv)
router.Handle("/playground", playground.Handler("GraphQL playground", "/query"))
for _, schema := range g.app.GraphSchemas() {
router.Handle(filepath.Join(fmt.Sprintf("/query/%s", schema.BasePath)), graphql.NewHandler(executor.New(schema.Value)))
exec := executor.New(schema.Value)
if schema.ExecutorCb != nil {
schema.ExecutorCb(exec)
}
router.Handle(filepath.Join(fmt.Sprintf("/query/%s", schema.BasePath)), graphql.NewHandler(exec))
}
log.Printf("connect to http://localhost:%d/playground for GraphQL playground", configuration.Use().ServerPort)
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/application/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package application
import (
"context"
"embed"

"github.com/iota-uz/iota-sdk/modules/core/domain/entities/permission"
"github.com/iota-uz/iota-sdk/pkg/spotlight"
"github.com/jackc/pgx/v5/pgxpool"

"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/executor"
"github.com/benbjohnson/hashfs"
"github.com/gorilla/mux"
"github.com/iota-uz/iota-sdk/pkg/eventbus"
Expand All @@ -16,8 +18,9 @@ import (
)

type GraphSchema struct {
Value graphql.ExecutableSchema
BasePath string
Value graphql.ExecutableSchema
BasePath string
ExecutorCb func(*executor.Executor)
}

// Application with a dynamically extendable service registry
Expand Down

0 comments on commit 5464f41

Please sign in to comment.