@@ 4,7 4,6 @@ go 1.20
require (
git.sr.ht/~sircmpwn/dowork v0.0.0-20221010085743-46c4299d76a1
- github.com/99designs/gqlgen v0.17.29
github.com/Masterminds/squirrel v1.5.4
github.com/alexedwards/argon2id v1.0.0
github.com/alexedwards/scs/postgresstore v0.0.0-20211203064041-370cc303b69f
@@ 23,7 22,6 @@ require (
require (
github.com/ProtonMail/go-crypto v0.0.0-20220930113650-c6815a8c17ad // indirect
- github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cloudflare/circl v1.2.0 // indirect
@@ 37,8 35,6 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/gopherjs/gopherjs v0.0.0-20220221023154-0b2280d3ff96 // indirect
- github.com/gorilla/websocket v1.5.0 // indirect
- github.com/hashicorp/golang-lru/v2 v2.0.1 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/klauspost/compress v1.13.5 // indirect
@@ 53,7 49,6 @@ require (
github.com/minio/md5-simd v1.1.0 // indirect
github.com/minio/sha256-simd v0.1.1 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
- github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
@@ 65,7 60,6 @@ require (
github.com/smartystreets/assertions v1.2.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
- github.com/vektah/gqlparser/v2 v2.5.1 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/time v0.5.0 // indirect
@@ 33,8 33,6 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
git.sr.ht/~sircmpwn/dowork v0.0.0-20221010085743-46c4299d76a1 h1:EvPKkneKkF/f7zEgKPqIZVyj3jWO8zSmsBOvMhAGqMA=
git.sr.ht/~sircmpwn/dowork v0.0.0-20221010085743-46c4299d76a1/go.mod h1:8neHEO3503w/rNtttnR0JFpQgM/GFhaafVwvkPsFIDw=
-github.com/99designs/gqlgen v0.17.29 h1:z2MrNOFATCVgQLRCF6Uufz4uz2IQLB5BBMwPUMafJOA=
-github.com/99designs/gqlgen v0.17.29/go.mod h1:i4rEatMrzzu6RXaHydq1nmEPZkb3bKQsnxNRHS4DQB4=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
@@ 42,9 40,6 @@ github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA4
github.com/ProtonMail/go-crypto v0.0.0-20211112122917-428f8eabeeb3/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/ProtonMail/go-crypto v0.0.0-20220930113650-c6815a8c17ad h1:QeeqI2zxxgZVe11UrYFXXx6gVxPVF40ygekjBzEg4XY=
github.com/ProtonMail/go-crypto v0.0.0-20220930113650-c6815a8c17ad/go.mod h1:UBYPn8k0D56RtnR8RFQMjmh4KrZzWJ5o7Z9SYjossQ8=
-github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
-github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
-github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
@@ 56,10 51,6 @@ github.com/alexedwards/scs/postgresstore v0.0.0-20211203064041-370cc303b69f h1:5
github.com/alexedwards/scs/postgresstore v0.0.0-20211203064041-370cc303b69f/go.mod h1:TDDdV/xnjj+/4zBQ9a2k+i2AbuAdY7SQjPUh5zoTZ3M=
github.com/alexedwards/scs/v2 v2.7.0 h1:DY4rqLCM7UIR9iwxFS0++z1NhTzQlKV30aMHkJCDWKw=
github.com/alexedwards/scs/v2 v2.7.0/go.mod h1:ToaROZxyKukJKT/xLcVQAChi5k6+Pn1Gvmdl7h3RRj8=
-github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
-github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
-github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
-github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ 81,8 72,6 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g=
-github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/emersion/go-message v0.15.0/go.mod h1:wQUEfE+38+7EW8p8aZ96ptg6bAb1iwdgej19uXASlE4=
@@ 175,12 164,8 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20220221023154-0b2280d3ff96 h1:QJq7UBOuoynsywLk+aC75rC2Cbi2+lQRDaLaizhA+fA=
github.com/gopherjs/gopherjs v0.0.0-20220221023154-0b2280d3ff96/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
-github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
-github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
-github.com/hashicorp/golang-lru/v2 v2.0.1 h1:5pv5N1lT1fjLg2VQ5KWc7kmucp2x/kvFOnxuVTqZ6x4=
-github.com/hashicorp/golang-lru/v2 v2.0.1/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
@@ 235,8 220,6 @@ github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKU
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
-github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
-github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ 282,8 265,6 @@ github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rwtodd/Go.Sed v0.0.0-20210816025313-55464686f9ef/go.mod h1:8AEUvGVi2uQ5b24BIhcr0GCcpd/RNAFWaN2CJFrWIIQ=
github.com/segmentio/ksuid v1.0.4 h1:sBo2BdShXjmcugAMwjugoGUdUV0pcxY5mW4xKRn3v4c=
github.com/segmentio/ksuid v1.0.4/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE=
-github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
-github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
@@ 310,8 291,6 @@ github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQ
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec h1:DGmKwyZwEB8dI7tbLt/I/gQuP559o/0FrAkHKlQM/Ks=
github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec/go.mod h1:owBmyHYMLkxyrugmfwE/DLJyW8Ro9mkphwuVErQ0iUw=
-github.com/vektah/gqlparser/v2 v2.5.1 h1:ZGu+bquAY23jsxDRcYpWjttRZrUz07LbiY77gUOHcr4=
-github.com/vektah/gqlparser/v2 v2.5.1/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ 630,9 609,7 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
@@ 4,28 4,19 @@ import (
"bytes"
"context"
"database/sql"
- "encoding/json"
"errors"
"fmt"
"html/template"
- "io"
"io/fs"
"net/http"
"os"
"os/signal"
"runtime"
- "strconv"
"strings"
"syscall"
"time"
work "git.sr.ht/~sircmpwn/dowork"
- "github.com/99designs/gqlgen/graphql"
- "github.com/99designs/gqlgen/graphql/handler"
- "github.com/99designs/gqlgen/graphql/handler/extension"
- "github.com/99designs/gqlgen/graphql/handler/lru"
- "github.com/99designs/gqlgen/graphql/handler/transport"
- "github.com/99designs/gqlgen/graphql/playground"
"github.com/alexedwards/scs/postgresstore"
"github.com/alexedwards/scs/v2"
"github.com/labstack/echo/v4"
@@ 67,13 58,6 @@ type Extension interface {
Extend(gserver *Server) (*Server, error)
}
-// GraphQL is a holder for a graphql schema and options
-type GraphQL struct {
- Schema graphql.ExecutableSchema
- MaxComplexity int
- MaxUploadSize int
-}
-
// MiddlewareConfig is a config struct to set default middlewares
type MiddlewareConfig struct {
Sessions bool
@@ 100,7 84,6 @@ type Server struct {
Session *scs.SessionManager
Email *email.ServiceQueue
Storage storage.Service
- GQL *GraphQL
e *echo.Echo
ai *appInfo
@@ 271,104 254,6 @@ The following stack trace was produced:
}
}
-func (s *Server) gqlEmailRecover(ctx context.Context, _origErr any) error {
- s.e.Logger.Print(_origErr)
- var (
- ok bool
- origErr error
- )
- if origErr, ok = _origErr.(error); !ok {
- s.e.Logger.Printf("Unexpected error in recover: %v\n", origErr)
- return fmt.Errorf("internal system error")
- }
-
- if origErr.Error() == "context canceled" || errors.Is(origErr, context.Canceled) {
- return origErr
- }
-
- if errors.Is(origErr, context.DeadlineExceeded) {
- return origErr
- }
-
- if origErr.Error() == "pq: canceling statement due to user request" {
- return origErr
- }
-
- stack := make([]byte, 32768) // 32 KiB
- i := runtime.Stack(stack, false)
- stack = stack[:i]
- _, file, line, _ := runtime.Caller(2)
- s.e.Logger.Print(origErr.Error())
-
- // Print debug info
- if s.Config.Debug {
- s.e.Logger.Print(string(stack))
- fmt.Fprintf(os.Stderr, string(stack))
- }
-
- if s.Config.Debug || !s.Config.EmailAdminErrors || s.Email == nil {
- return fmt.Errorf("internal system error")
- }
-
- var (
- reader io.Reader
- userEmail string
- )
- func() {
- defer func() {
- if err := recover(); err != nil {
- reader = strings.NewReader(fmt.Sprintf(`An error occured outside of the GraphQL context:
-
- %s`, stack))
- }
- }()
- c := EchoForContext(ctx)
- gctx := c.(*Context)
- if gctx.User != nil && gctx.User.IsAuthenticated() {
- userEmail = gctx.User.GetEmail()
- } else {
- userEmail = "unauthenticated"
- }
- octx := graphql.GetOperationContext(ctx)
- vars, err := json.Marshal(octx.Variables)
- if err != nil {
- vars = []byte{}[:]
- }
- reader = strings.NewReader(
- fmt.Sprintf(`Error occured processing GraphQL request:
-
-%v
-
-When running the following query on behalf of %s:
-
-%s
-
-With these variables:
-
-%s
-
-Attempted to collect final caller:
-
-%s:%d
-
-The following stack trace was produced:
-
-%s`, origErr, userEmail, octx.RawQuery, string(vars), file, line, stack))
- }()
-
- msg := carrier.NewMessage().
- SetTo(s.Config.AdminEmail).
- SetFrom(s.Config.DefaultFromEmail)
- appName := strings.Split(s.AppInfo(), " ")[0]
- msg.SetSubject(fmt.Sprintf("[gobwebs %s]: GraphQL query error: %v", appName, origErr))
- msg.SetText(reader)
- if rerr := s.Email.SendMail(msg); rerr != nil {
- s.e.Logger.Printf("Unable to send admin error email: %v", rerr)
- }
-
- return fmt.Errorf("internal system error")
-}
-
// LogErrorFunc will handle logging the stack trace for an error
func (s *Server) LogErrorFunc(c echo.Context, err error, stack []byte) error {
msg := fmt.Sprintf("[PANIC RECOVER] %s\n%v\n%s\n", c.Path(), c.QueryParams(), stack)
@@ 497,88 382,6 @@ func (s *Server) Extend(ext Extension) (*Server, error) {
return ext.Extend(s)
}
-// WithSchema Adds a GraphQL schema for this server. The second parameter
-// shall be the list of scopes, as strings, which are supported by this
-// schema. This function configures routes for the router; all middlewares
-// must be configured before this is called.
-func (s *Server) WithSchema(
- schema graphql.ExecutableSchema, scopes []string) *Server {
- gql := &GraphQL{Schema: schema}
-
- var err error
- if limit, ok := s.Config.File.Get(
- "graphql", "max-complexity"); ok {
- gql.MaxComplexity, err = strconv.Atoi(limit)
- if err != nil {
- panic(err)
- }
- } else {
- gql.MaxComplexity = 250
- }
- if size, ok := s.Config.File.Get(
- "graphql", "max-upload-size"); ok {
- gql.MaxUploadSize, err = strconv.Atoi(size)
- if err != nil {
- panic(err)
- }
- } else {
- gql.MaxUploadSize = 10737418 // 10MB
- }
- s.GQL = gql
-
- srv := handler.New(schema)
- srv.AddTransport(transport.Websocket{
- KeepAlivePingInterval: 10 * time.Second,
- })
- srv.AddTransport(transport.Options{})
- srv.AddTransport(transport.GET{})
- srv.AddTransport(transport.POST{})
- srv.AddTransport(transport.MultipartForm{
- MaxUploadSize: int64(gql.MaxUploadSize),
- })
-
- srv.SetQueryCache(lru.New(1000))
-
- srv.Use(extension.Introspection{})
- srv.Use(extension.AutomaticPersistedQuery{
- Cache: lru.New(100),
- })
-
- srv.SetRecoverFunc(s.gqlEmailRecover)
- srv.Use(extension.FixedComplexityLimit(gql.MaxComplexity))
-
- if s.Config.Debug {
- s.e.GET("/graphql", func(c echo.Context) error {
- // Gross
- ctx := EchoContext(c.Request().Context(), c)
- c.SetRequest(c.Request().WithContext(ctx))
- phand := playground.Handler("GraphQL playground", "/query")
- phand.ServeHTTP(c.Response(), c.Request())
- return nil
- })
- }
- s.e.POST("/query", func(c echo.Context) error {
- // More gross
- ctx := EchoContext(c.Request().Context(), c)
- c.SetRequest(c.Request().WithContext(ctx))
- srv.ServeHTTP(c.Response(), c.Request())
- return nil
- })
- s.e.GET("/query/api-scopes.json", func(c echo.Context) error {
- info := struct {
- Scopes []string `json:"scopes"`
- }{scopes}
-
- //j, err := json.Marshal(&info)
- //if err != nil {
- // panic(err)
- //}
-
- return c.JSON(http.StatusOK, &info)
- })
- return s
-}
-
// WithDefaultMiddleware sets default middleware for the application
func (s *Server) WithDefaultMiddleware() *Server {
conf := &MiddlewareConfig{