From 9f03583edfc3feeb55bc26670f5ca6ef207cb151 Mon Sep 17 00:00:00 2001 From: gearnode Date: Fri, 28 Feb 2025 10:57:06 +0100 Subject: [PATCH] Add multipart form transport support Will allow to upload file via the GrahQL API Signed-off-by: gearnode --- pkg/api/console/v1/resolver.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/api/console/v1/resolver.go b/pkg/api/console/v1/resolver.go index faf2b034e..0c64161f8 100644 --- a/pkg/api/console/v1/resolver.go +++ b/pkg/api/console/v1/resolver.go @@ -91,6 +91,8 @@ func NewMux(proboSvc *probo.Service, usrmgrSvc *usrmgr.Service, authCfg AuthConf } func graphqlHandler(proboSvc *probo.Service, usrmgrSvc *usrmgr.Service, authCfg AuthConfig) http.HandlerFunc { + var mb int64 = 1 << 20 + es := schema.NewExecutableSchema( schema.Config{ Resolvers: &Resolver{ @@ -102,6 +104,10 @@ func graphqlHandler(proboSvc *probo.Service, usrmgrSvc *usrmgr.Service, authCfg ) srv := handler.New(es) srv.AddTransport(transport.POST{}) + srv.AddTransport(transport.MultipartForm{ + MaxMemory: 32 * mb, + MaxUploadSize: 50 * mb, + }) srv.Use(extension.Introspection{}) // Add operation middleware for authentication