Skip to content

Commit

Permalink
fix: fix gqlgen usage
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyno-zeta authored Dec 10, 2024
1 parent ab1927a commit 30422c8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions backend/pkg/golang-graphql-example/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (
gqlerrorcode "github.com/99designs/gqlgen/graphql/errcode"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/extension"
"github.com/99designs/gqlgen/graphql/handler/lru"
"github.com/99designs/gqlgen/graphql/handler/transport"
"github.com/99designs/gqlgen/graphql/handler/extension"
gqlplayground "github.com/99designs/gqlgen/graphql/playground"
helmet "github.com/danielkov/gin-helmet"
"github.com/gin-contrib/gzip"
Expand All @@ -35,6 +38,7 @@ import (
gutils "github.com/oxyno-zeta/golang-graphql-example/pkg/golang-graphql-example/server/graphql/utils"
"github.com/oxyno-zeta/golang-graphql-example/pkg/golang-graphql-example/signalhandler"
"github.com/oxyno-zeta/golang-graphql-example/pkg/golang-graphql-example/tracing"
"github.com/vektah/gqlparser/v2/ast"
"github.com/vektah/gqlparser/v2/gqlerror"
)

Expand Down Expand Up @@ -246,6 +250,21 @@ func (svr *Server) graphqlHandler(busiServices *business.Services) gin.HandlerFu
},
},
}))

h.AddTransport(transport.Websocket{
KeepAlivePingInterval: 10 * time.Second, //nolint:mnd
})
h.AddTransport(transport.Options{})
h.AddTransport(transport.GET{})
h.AddTransport(transport.POST{})
h.AddTransport(transport.MultipartForm{})

h.SetQueryCache(lru.New[*ast.QueryDocument](1000)) //nolint:mnd

h.Use(extension.Introspection{})
h.Use(extension.AutomaticPersistedQuery{
Cache: lru.New[string](100), //nolint:mnd
})
h.Use(svr.tracingSvc.GraphqlMiddleware())
h.Use(svr.metricsSvc.GraphqlMiddleware())
h.Use(extension.FixedComplexityLimit(GraphqlComplexityLimit))
Expand Down

0 comments on commit 30422c8

Please sign in to comment.