Export the graphql subrouter
@@ -29,6 +29,7 @@ type APId struct {
Authenticator *authentication.Authenticator
HTTPServer *http.Server
CoreSubrouter *mux.Router
+ GraphQLSubrouter *mux.Router
stopping chan struct{}
running *atomic.Value
@@ -101,7 +102,7 @@ func New(c Config, opts ...Option) (*APId, error) {
router.NotFoundHandler = middlewares.SimpleLogger{}.Then(http.HandlerFunc(notFoundHandler))
router.Handle("/metrics", promhttp.Handler())
registerUnauthenticatedResources(router, a.store, a.cluster, a.etcdClientTLSConfig)
- registerGraphQLService(router, a.store, c.URL, tlsClientConfig)
+ a.registerGraphQLService(router, c.URL, tlsClientConfig)
registerAuthenticationResources(router, a.store, a.Authenticator)
a.registerRestrictedResources(router)
@@ -196,9 +197,8 @@ func registerUnauthenticatedResources(
)
}
-func registerGraphQLService(router *mux.Router, store store.Store, url string, tls *tls.Config) {
- mountRouters(
- NewSubrouter(
+func (a *APId) registerGraphQLService(router *mux.Router, url string, tls *tls.Config) {
+ a.GraphQLSubrouter = NewSubrouter(
router.NewRoute(),
middlewares.SimpleLogger{},
middlewares.LimitRequest{},
@@ -211,9 +211,11 @@ func registerGraphQLService(router *mux.Router, store store.Store, url string, t
// https://github.com/graphql/graphiql
// https://graphql.org/learn/introspection/
middlewares.Authentication{IgnoreUnauthorized: false},
- middlewares.AllowList{Store: store, IgnoreMissingClaims: true},
- ),
- routers.NewGraphQLRouter(url, tls, store),
+ middlewares.AllowList{Store: a.store, IgnoreMissingClaims: true},
+ )
+ mountRouters(
+ a.GraphQLSubrouter,
+ routers.NewGraphQLRouter(url, tls, a.store),
)
}
