GraphQL (part 2): Model changes and resolvers (#19486)

This PR adds the necessary resolvers to support
the graphQL front-end. Some additional methods
need to be added to the model structs to support
this. Comments have been made to clarify their purpose.

There is a slight duplication of code in the api layer.
But eventually that's going to go away when we move
away from the REST API entirely.

The schema is in api4/schema.graphqls and gets compiled
into the binary as an asset.

The GraphiQL editor url is at GET /api/v5/graphql.

Everything is behind the feature flag MM_FEATUREFLAGS_GRAPHQL.

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2022-02-11 12:37:05 +05:30
коммит произвёл GitHub
родитель 88968f9e17
Коммит 3f52bd197a
93 изменённых файлов: 9479 добавлений и 22 удалений

Просмотреть файл

@@ -73,7 +73,7 @@ func runServer(configStore *config.Store, interruptChan chan os.Signal) error {
}
server, err := app.NewServer(options...)
if err != nil {
mlog.Critical(err.Error())
mlog.Error(err.Error())
return err
}
defer server.Shutdown()
@@ -86,20 +86,24 @@ func runServer(configStore *config.Store, interruptChan chan os.Signal) error {
if x := recover(); x != nil {
var buf bytes.Buffer
pprof.Lookup("goroutine").WriteTo(&buf, 2)
mlog.Critical("A panic occurred",
mlog.Error("A panic occurred",
mlog.Any("error", x),
mlog.String("stack", buf.String()))
panic(x)
}
}()
api := api4.Init(server)
api, err := api4.Init(server)
if err != nil {
mlog.Error(err.Error())
return err
}
wsapi.Init(server)
web.New(server)
err = server.Start()
if err != nil {
mlog.Critical(err.Error())
mlog.Error(err.Error())
return err
}

Просмотреть файл

@@ -58,7 +58,10 @@ func webClientTestsCmdF(command *cobra.Command, args []string) error {
return serverErr
}
api4.Init(a.Srv())
_, err = api4.Init(a.Srv())
if err != nil {
return err
}
wsapi.Init(a.Srv())
a.UpdateConfig(setupClientTests)
runWebClientTests()
@@ -79,7 +82,10 @@ func serverForWebClientTestsCmdF(command *cobra.Command, args []string) error {
return serverErr
}
api4.Init(a.Srv())
_, err = api4.Init(a.Srv())
if err != nil {
return err
}
wsapi.Init(a.Srv())
a.UpdateConfig(setupClientTests)