Skip to content

Commit

Permalink
chore(server): handler for gql has extension loaded twice (#1335)
Browse files Browse the repository at this point in the history
Co-authored-by: YuyaSoneda <[email protected]>
  • Loading branch information
soneda-yuya and YuyaSoneda authored Jan 7, 2025
1 parent d6d6f0b commit 255d3c2
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions server/internal/app/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,19 @@ func GraphqlAPI(conf config.GraphQLConfig, dev bool) echo.HandlerFunc {
MaxMemory: maxMemorySize,
})

// cache settings
srv.SetQueryCache(lru.New(1000))

srv.Use(extension.Introspection{})
srv.Use(extension.AutomaticPersistedQuery{
Cache: lru.New(100),
Cache: lru.New(30),
})

srv.Use(otelgqlgen.Middleware())

// complexity limit
if conf.ComplexityLimit > 0 {
srv.Use(extension.FixedComplexityLimit(conf.ComplexityLimit))
}

if dev {
srv.Use(extension.Introspection{})
}

srv.Use(extension.AutomaticPersistedQuery{
Cache: lru.New(30),
})
// tracing
srv.Use(otelgqlgen.Middleware())

srv.SetErrorPresenter(
// show more detailed error messgage in debug mode
Expand All @@ -72,6 +65,11 @@ func GraphqlAPI(conf config.GraphQLConfig, dev bool) echo.HandlerFunc {
},
)

// only enable middlewares in dev mode
if dev {
srv.Use(extension.Introspection{})
}

return func(c echo.Context) error {
req := c.Request()
ctx := req.Context()
Expand Down

0 comments on commit 255d3c2

Please sign in to comment.