Skip to content

isgasho/echo_graphql

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

echo with graphql-go

Basic use

import (
	"github.com/graph-gophers/graphql-go"
	"github.com/labstack/echo"
)

e := echo.New()
e.Any("/graphql", echo_graphql.NewEchoHandle(echo_graphql.EchoHandleOptions{
	Schema: graphql.MustParseSchema(`your graphql schema define content...`),
}))

Use cache to improve performance

cache all graphql request by body hash

import (
	"github.com/graph-gophers/graphql-go"
	"github.com/labstack/echo"
	"github.com/gwuhaolin/lfucache"
)

e := echo.New()
graphqlSchema := graphql.MustParseSchema(`your graphql schema define content...`)

e.Any("/graphql", echo_graphql.NewEchoHandle(echo_graphql.EchoHandleOptions{
	Schema: graphqlSchema,
    Cache:  lfucache.NewLfuCache(1024),
}))

skip cache some request

e := echo.New()
graphqlSchema := graphql.MustParseSchema(`your graphql schema define content...`)

e.Any("/graphql", echo_graphql.NewEchoHandle(echo_graphql.EchoHandleOptions{
	Schema: graphqlSchema, 
    Cache:  lfucache.NewLfuCache(1024),
    SkipCache: func(params *Params){
        retuen true // don't cache this request
    }
}))

About

a echo handle func for graphql-go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%