I'm building a new project in Golang world and I wanna try this amazing framework. What do you think about GraphQL?
Is it worth having a framework like Gin for this purpose?
If I search "graphql" in these issues nothing appears.
Comment From: remyr
I'm using Gin with GraphQL and it's work like a charm. You just need to create a custom handler to handle your graphql query. I can provide you some example for the handler if you need.
Comment From: appleboy
@mrkongo create the gin middleware:
package graphql
import (
"github.com/go-ggz/ggz/schema"
"github.com/gin-gonic/gin"
"github.com/graphql-go/handler"
)
// Handler initializes the prometheus middleware.
func Handler() gin.HandlerFunc {
// Creates a GraphQL-go HTTP handler with the defined schema
h := handler.New(&handler.Config{
Schema: &schema.Schema,
Pretty: true,
})
return func(c *gin.Context) {
h.ServeHTTP(c.Writer, c.Request)
}
}
in router:
g := e.Group("/graphql")
g.Use(auth0.Check())
{
g.POST("", graphql.Handler())
}
try it.
Comment From: mozillo
Did Gin support subscription of GraphQL
Comment From: appleboy
@mozillo
See https://medium.com/functional-foundry/building-graphql-servers-with-subscriptions-in-go-2a60f11dc9f5
https://github.com/functionalfoundry/graphqlws
Comment From: kamalkech
there is no alternative compatible for current version, currently i am using Echo with go 1.23