Embedded javascript plugins (#1393)

This commit is contained in:
WithoutPants
2021-05-26 14:17:53 +10:00
committed by GitHub
parent cc5ec650ae
commit 9b57fbbf50
108 changed files with 30179 additions and 91 deletions

View File

@@ -9,6 +9,7 @@ package plugin
import (
"fmt"
"net/http"
"os"
"path/filepath"
@@ -19,8 +20,9 @@ import (
// Cache stores plugin details.
type Cache struct {
path string
plugins []Config
path string
plugins []Config
gqlHandler http.HandlerFunc
}
// NewCache returns a new Cache loading plugin configurations
@@ -41,6 +43,10 @@ func NewCache(pluginPath string) (*Cache, error) {
}, nil
}
func (c *Cache) RegisterGQLHandler(handler http.HandlerFunc) {
c.gqlHandler = handler
}
// ReloadPlugins clears the plugin cache and reloads from the plugin path.
// In the event of an error during loading, the cache will be left empty.
func (c *Cache) ReloadPlugins() error {
@@ -125,6 +131,7 @@ func (c Cache) CreateTask(pluginID string, operationName string, serverConnectio
serverConnection: serverConnection,
args: args,
progress: progress,
gqlHandler: c.gqlHandler,
}
return task.createTask(), nil
}