mirror of https://github.com/stashapp/stash.git
Fix dataloaders not loading in js plugins (#3014)
* Include dataloaders in js plugin gql calls * Handle gql errors correctly in js plugins
This commit is contained in:
parent
bd44571a91
commit
4c286d7ab5
|
@ -122,7 +122,9 @@ func Start() error {
|
|||
|
||||
// register GQL handler with plugin cache
|
||||
// chain the visited plugin handler
|
||||
manager.GetInstance().PluginCache.RegisterGQLHandler(visitedPluginHandler(http.HandlerFunc(gqlHandlerFunc)))
|
||||
// also requires the dataloader middleware
|
||||
gqlHandler := visitedPluginHandler(dataloaders.Middleware(http.HandlerFunc(gqlHandlerFunc)))
|
||||
manager.GetInstance().PluginCache.RegisterGQLHandler(gqlHandler)
|
||||
|
||||
r.HandleFunc("/graphql", gqlHandlerFunc)
|
||||
r.HandleFunc("/playground", gqlPlayground.Handler("GraphQL playground", "/graphql"))
|
||||
|
|
|
@ -89,10 +89,11 @@ func gqlRequestFunc(ctx context.Context, vm *otto.Otto, cookie *http.Cookie, gql
|
|||
throw(vm, fmt.Sprintf("could not unmarshal object %s: %s", output, err.Error()))
|
||||
}
|
||||
|
||||
retErr, hasErr := obj["error"]
|
||||
retErr, hasErr := obj["errors"]
|
||||
|
||||
if hasErr {
|
||||
throw(vm, fmt.Sprintf("graphql error: %v", retErr))
|
||||
errOut, _ := json.Marshal(retErr)
|
||||
throw(vm, fmt.Sprintf("graphql error: %s", string(errOut)))
|
||||
}
|
||||
|
||||
v, err := vm.ToValue(obj["data"])
|
||||
|
|
Loading…
Reference in New Issue