~bigbes/core-go

ba01be8449eadd60ffae7ae28f27247bbefa8bcc — Conrad Hoffmann 1 year, 1 month ago e36951d
server: replace deprecated gqlgen code

Most of the gqlgen/handler package, specifically also
`handler.GraphQL()`, has been deprecated [1]. The documentation of the
new package [2] is a bit lacking, but some stuff is covered in the
reference docs [3] [4], and some in the examples [5].

[1] https://pkg.go.dev/github.com/99designs/gqlgen@v0.17.36/handler#GraphQL
[2] https://pkg.go.dev/github.com/99designs/gqlgen@v0.17.36/graphql/handler
[3] https://gqlgen.com/reference/errors/#the-panic-handler
[4] https://gqlgen.com/reference/complexity/#limiting-query-complexity
[5] https://github.com/99designs/gqlgen/blob/master/_examples/fileupload/server/server.go
1 files changed, 11 insertions(+), 5 deletions(-)

M server/server.go
M server/server.go => server/server.go +11 -5
@@ 17,8 17,10 @@ import (

	work "git.sr.ht/~sircmpwn/dowork"
	"github.com/99designs/gqlgen/graphql"
	"github.com/99designs/gqlgen/graphql/handler"
	"github.com/99designs/gqlgen/graphql/handler/extension"
	"github.com/99designs/gqlgen/graphql/handler/transport"
	"github.com/99designs/gqlgen/graphql/playground"
	"github.com/99designs/gqlgen/handler"
	"github.com/go-chi/chi/v5"
	"github.com/go-chi/chi/v5/middleware"
	goRedis "github.com/go-redis/redis/v8"


@@ 108,10 110,14 @@ func (server *Server) WithSchema(
		server.MaxComplexity = 250
	}

	srv := handler.GraphQL(schema,
		handler.ComplexityLimit(server.MaxComplexity),
		handler.RecoverFunc(EmailRecover),
		handler.UploadMaxSize(1073741824)) // 1 GiB (TODO: configurable?)
	srv := handler.New(schema)
	srv.Use(extension.FixedComplexityLimit(server.MaxComplexity))
	srv.SetRecoverFunc(EmailRecover)
	srv.AddTransport(transport.POST{})
	srv.AddTransport(transport.MultipartForm{
		MaxMemory:     33554432,   // 32 MiB (up to this handled in memory)
		MaxUploadSize: 1073741824, // 1 GiB (TODO: configurable?)
	})

	server.router.Handle("/query", srv)