New: Proxy all the requests to the graphql server

This commit is contained in:
2023-10-11 11:26:55 +01:00
parent dd25e4a4a5
commit f41b2ae46f
6 changed files with 18 additions and 10 deletions
+8 -2
View File
@@ -21,7 +21,8 @@ func StartHTTPProxy() {
AllowOrigins: "*",
}))
server.Post("/v1/graphql", processGraphQLRequest)
server.Post("/*", processGraphQLRequest)
server.Get("/*", proxyTheRequest)
server.Get("/healthz", healthCheck)
err := server.Listen(fmt.Sprintf(":%d", cfg.Server.PortGraphQL))
@@ -70,11 +71,16 @@ func processGraphQLRequest(c *fiber.Ctx) error {
}
}
opType, opName, cacheFromQuery, cache_time, shouldBlock := parseGraphQLQuery(c)
opType, opName, cacheFromQuery, cache_time, shouldBlock, should_ignore := parseGraphQLQuery(c)
if shouldBlock {
return nil
}
if should_ignore {
cfg.Logger.Debug("Request passed as-is - not a GraphQL")
return proxyTheRequest(c)
}
if cache_time > 0 {
cfg.Logger.Debug("Cache time set via query", map[string]interface{}{"cache_time": cache_time})
cache_time = cfg.Cache.CacheTTL