aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/99designs
diff options
context:
space:
mode:
authorMichael Muré <michael.mure@consensys.net>2019-03-31 21:44:14 +0200
committerMichael Muré <batolettre@gmail.com>2019-04-01 14:03:13 +0200
commit15c258cdc4ba37820362a44dfc2636ed1ff92b4c (patch)
tree0790e36bf4846b12b367f12670540eec6ee023f3 /vendor/github.com/99designs
parente028b895aa21553937d732044b7bb0a15c5276f6 (diff)
downloadgit-bug-15c258cdc4ba37820362a44dfc2636ed1ff92b4c.tar.gz
graphql: expose allIdentities, identities and userIdentity in the repo
Diffstat (limited to 'vendor/github.com/99designs')
-rw-r--r--vendor/github.com/99designs/gqlgen/graphql/version.go2
-rw-r--r--vendor/github.com/99designs/gqlgen/handler/graphql.go28
-rw-r--r--vendor/github.com/99designs/gqlgen/handler/websocket.go42
3 files changed, 55 insertions, 17 deletions
diff --git a/vendor/github.com/99designs/gqlgen/graphql/version.go b/vendor/github.com/99designs/gqlgen/graphql/version.go
index 8cf3c9ba..490ff3ff 100644
--- a/vendor/github.com/99designs/gqlgen/graphql/version.go
+++ b/vendor/github.com/99designs/gqlgen/graphql/version.go
@@ -1,3 +1,3 @@
package graphql
-const Version = "dev"
+const Version = "v0.7.2"
diff --git a/vendor/github.com/99designs/gqlgen/handler/graphql.go b/vendor/github.com/99designs/gqlgen/handler/graphql.go
index eb8880de..7c5f70cf 100644
--- a/vendor/github.com/99designs/gqlgen/handler/graphql.go
+++ b/vendor/github.com/99designs/gqlgen/handler/graphql.go
@@ -7,6 +7,7 @@ import (
"io"
"net/http"
"strings"
+ "time"
"github.com/99designs/gqlgen/complexity"
"github.com/99designs/gqlgen/graphql"
@@ -25,15 +26,16 @@ type params struct {
}
type Config struct {
- cacheSize int
- upgrader websocket.Upgrader
- recover graphql.RecoverFunc
- errorPresenter graphql.ErrorPresenterFunc
- resolverHook graphql.FieldMiddleware
- requestHook graphql.RequestMiddleware
- tracer graphql.Tracer
- complexityLimit int
- disableIntrospection bool
+ cacheSize int
+ upgrader websocket.Upgrader
+ recover graphql.RecoverFunc
+ errorPresenter graphql.ErrorPresenterFunc
+ resolverHook graphql.FieldMiddleware
+ requestHook graphql.RequestMiddleware
+ tracer graphql.Tracer
+ complexityLimit int
+ disableIntrospection bool
+ connectionKeepAlivePingInterval time.Duration
}
func (c *Config) newRequestContext(es graphql.ExecutableSchema, doc *ast.QueryDocument, op *ast.OperationDefinition, query string, variables map[string]interface{}) *graphql.RequestContext {
@@ -243,6 +245,14 @@ func CacheSize(size int) Option {
const DefaultCacheSize = 1000
+// WebsocketKeepAliveDuration allows you to reconfigure the keepAlive behavior.
+// By default, keep-alive is disabled.
+func WebsocketKeepAliveDuration(duration time.Duration) Option {
+ return func(cfg *Config) {
+ cfg.connectionKeepAlivePingInterval = duration
+ }
+}
+
func GraphQL(exec graphql.ExecutableSchema, options ...Option) http.HandlerFunc {
cfg := &Config{
cacheSize: DefaultCacheSize,
diff --git a/vendor/github.com/99designs/gqlgen/handler/websocket.go b/vendor/github.com/99designs/gqlgen/handler/websocket.go
index dae262bd..09800c17 100644
--- a/vendor/github.com/99designs/gqlgen/handler/websocket.go
+++ b/vendor/github.com/99designs/gqlgen/handler/websocket.go
@@ -8,6 +8,7 @@ import (
"log"
"net/http"
"sync"
+ "time"
"github.com/99designs/gqlgen/graphql"
"github.com/gorilla/websocket"
@@ -27,7 +28,7 @@ const (
dataMsg = "data" // Server -> Client
errorMsg = "error" // Server -> Client
completeMsg = "complete" // Server -> Client
- //connectionKeepAliveMsg = "ka" // Server -> Client TODO: keepalives
+ connectionKeepAliveMsg = "ka" // Server -> Client
)
type operationMessage struct {
@@ -37,12 +38,13 @@ type operationMessage struct {
}
type wsConnection struct {
- ctx context.Context
- conn *websocket.Conn
- exec graphql.ExecutableSchema
- active map[string]context.CancelFunc
- mu sync.Mutex
- cfg *Config
+ ctx context.Context
+ conn *websocket.Conn
+ exec graphql.ExecutableSchema
+ active map[string]context.CancelFunc
+ mu sync.Mutex
+ cfg *Config
+ keepAliveTicker *time.Ticker
initPayload InitPayload
}
@@ -109,6 +111,20 @@ func (c *wsConnection) write(msg *operationMessage) {
}
func (c *wsConnection) run() {
+ // We create a cancellation that will shutdown the keep-alive when we leave
+ // this function.
+ ctx, cancel := context.WithCancel(c.ctx)
+ defer cancel()
+
+ // Create a timer that will fire every interval to keep the connection alive.
+ if c.cfg.connectionKeepAlivePingInterval != 0 {
+ c.mu.Lock()
+ c.keepAliveTicker = time.NewTicker(c.cfg.connectionKeepAlivePingInterval)
+ c.mu.Unlock()
+
+ go c.keepAlive(ctx)
+ }
+
for {
message := c.readOp()
if message == nil {
@@ -141,6 +157,18 @@ func (c *wsConnection) run() {
}
}
+func (c *wsConnection) keepAlive(ctx context.Context) {
+ for {
+ select {
+ case <-ctx.Done():
+ c.keepAliveTicker.Stop()
+ return
+ case <-c.keepAliveTicker.C:
+ c.write(&operationMessage{Type: connectionKeepAliveMsg})
+ }
+ }
+}
+
func (c *wsConnection) subscribe(message *operationMessage) bool {
var reqParams params
if err := jsonDecode(bytes.NewReader(message.Payload), &reqParams); err != nil {