Skip to content

Commit

Permalink
chore:add graphql server listen address config (#1327)
Browse files Browse the repository at this point in the history
* chore:add graphql server listen address config

* Update node/config/types.go

Co-authored-by: Jacob Heun <[email protected]>

* Update node/config/def.go

Co-authored-by: Jacob Heun <[email protected]>

---------

Co-authored-by: Jacob Heun <[email protected]>
  • Loading branch information
rickiey and jacobheun authored Apr 27, 2023
1 parent 2c6d9fd commit 69d97c0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion gql/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func (s *Server) Start(ctx context.Context) error {

// Serve dummy deals
port := int(s.resolver.cfg.Graphql.Port)
bindAddress := s.resolver.cfg.Graphql.ListenAddress

err = serveDummyDeals(mux, port)
if err != nil {
return err
Expand Down Expand Up @@ -77,7 +79,7 @@ func (s *Server) Start(ctx context.Context) error {
}
wsHandler := graphqlws.NewHandlerFunc(schema, queryHandler, wsOpts...)

listenAddr := fmt.Sprintf(":%d", port)
listenAddr := fmt.Sprintf("%s:%d", bindAddress, port)
s.srv = &http.Server{Addr: listenAddr, Handler: mux}
fmt.Printf("Graphql server listening on %s\n", listenAddr)
mux.Handle("/graphql/subscription", &corsHandler{wsHandler})
Expand Down
3 changes: 2 additions & 1 deletion node/config/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func DefaultBoost() *Boost {
},

Graphql: GraphqlConfig{
Port: 8080,
ListenAddress: "0.0.0.0",
Port: 8080,
},

Tracing: TracingConfig{
Expand Down
2 changes: 2 additions & 0 deletions node/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ type WalletsConfig struct {
}

type GraphqlConfig struct {
// The ip address the GraphQL server will bind to. Default: 0.0.0.0
ListenAddress string
// The port that the graphql server listens on
Port uint64
}
Expand Down

0 comments on commit 69d97c0

Please sign in to comment.