Skip to content

Commit

Permalink
feat(config): support configuration of graphql path (#82)
Browse files Browse the repository at this point in the history
Co-authored-by: Dustin Deus <deusdustin@gmail.com>
  • Loading branch information
paulpdaniels and StarpTech authored Sep 18, 2023
1 parent 127614c commit 5fcb39a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions router/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func Main() {
core.WithIntrospection(cfg.IntrospectionEnabled),
core.WithPlayground(cfg.PlaygroundEnabled),
core.WithGraphApiToken(cfg.Graph.Token),
core.WithGraphQLPath(cfg.GraphQLPath),
core.WithModulesConfig(cfg.Modules),
core.WithGracePeriod(cfg.GracePeriod),
core.WithHealthCheckPath(cfg.HealthCheckPath),
Expand Down
6 changes: 5 additions & 1 deletion router/core/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ type (
// Alternatively, use Router.NewTestServer() to create a new Server instance without starting it for testing purposes.
func NewRouter(opts ...Option) (*Router, error) {
r := &Router{}
r.graphqlPath = "/graphql"

for _, opt := range opts {
opt(r)
Expand All @@ -111,6 +110,11 @@ func NewRouter(opts ...Option) (*Router, error) {
r.logger = zap.NewNop()
}

// Default value for graphql path
if r.graphqlPath == "" {
r.graphqlPath = "/graphql"
}

// Default values for trace and metric config

if r.traceConfig == nil {
Expand Down
1 change: 1 addition & 0 deletions router/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ type Config struct {
HealthCheckPath string `yaml:"health_check_path" default:"/health" envconfig:"HEALTH_CHECK_PATH" validate:"uri"`
ReadinessCheckPath string `yaml:"readiness_check_path" default:"/health/ready" envconfig:"READINESS_CHECK_PATH" validate:"uri"`
LivenessCheckPath string `yaml:"liveness_check_path" default:"/health/live" envconfig:"LIVENESS_CHECK_PATH" validate:"uri"`
GraphQLPath string `yaml:"graphql_path" default:"/graphql" envconfig:"GRAPHQL_PATH"`

ConfigPath string `default:"config.yaml" envconfig:"CONFIG_PATH" validate:"omitempty,filepath"`
RouterConfigPath string `yaml:"router_config_path" envconfig:"ROUTER_CONFIG_PATH" validate:"omitempty,filepath"`
Expand Down

0 comments on commit 5fcb39a

Please sign in to comment.