Issue enabling GraphQL subscriptions in Go; Playground doesn't detect the subscription - 'schema does not support subscriptions.'


In a GraphQL API in Go, I implemented subscriptions using gqlgen. I defined the ‘Subscription’ type to return either a boolean or the current server time. I ran the ‘generate’ command to apply the changes and obtain the autogenerated code. I implemented the logic in ‘schemaresolvers.go’ using goroutines. In ‘main.go,’ I configured the server with transports and websockets. However, the Playground does not detect the subscriptions, and I receive the following error when attempting to use ‘subscription’ in the Playground: ‘Schema does not support operation type “subscription”.’


func NewGraphQLHandler(dbInstance *gorm.DB) (http.Handler, error) {
	c := generated.Config{
		Resolvers: &graph.Resolver{
			DB: dbInstance,
	c.Directives.Auth = directives.Auth
	srv := handler.NewDefaultServer(generated.NewExecutableSchema(c))
	//agregar websocket, no detecta la subscription en el playground

	return srv, nil

Configuration main.go

func registerHandlers(lifecycle fx.Lifecycle, router *mux.Router, graphqlHandler http.Handler) {
	router.Handle("/", playground.Handler("GraphQL playground", "/query"))
	router.Handle("/query", graphqlHandler)
	router.Handle("/subscriptions", graphqlHandler)


func (r *subscriptionResolver) ServerEvents(ctx context.Context) (<-chan bool, error) {

	//creamos el channel
	result := make(chan bool)

	//go routine
	go func() {

		//el ping cada 5 segundos que se enviara al canal
		ticker := time.NewTicker(5 * time.Second)
		defer ticker.Stop()

		for {
			select {
			case <-ticker.C:
				result <- true //se envia true al canal
			case <-ctx.Done():
				//cuando el cliente se desconecta se cierra
				fmt.Println("Subscripcion cerrada")
	return result, nil


type Subscription {
    serverEvents: Boolean!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.