diff options
Diffstat (limited to 'graphql/resolvers/root.go')
-rw-r--r-- | graphql/resolvers/root.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/graphql/resolvers/root.go b/graphql/resolvers/root.go index 9973ff59..214bbae3 100644 --- a/graphql/resolvers/root.go +++ b/graphql/resolvers/root.go @@ -3,6 +3,7 @@ package resolvers import ( "github.com/MichaelMure/git-bug/cache" + "github.com/MichaelMure/git-bug/graphql/config" "github.com/MichaelMure/git-bug/graphql/graph" ) @@ -10,11 +11,13 @@ var _ graph.ResolverRoot = &RootResolver{} type RootResolver struct { cache.MultiRepoCache + cfg config.Config } -func NewRootResolver() *RootResolver { +func NewRootResolver(cfg config.Config) *RootResolver { return &RootResolver{ MultiRepoCache: cache.NewMultiRepoCache(), + cfg: cfg, } } @@ -25,13 +28,16 @@ func (r RootResolver) Query() graph.QueryResolver { } func (r RootResolver) Mutation() graph.MutationResolver { + if r.cfg.ReadOnly { + return &readonlyMutationResolver{} + } return &mutationResolver{ cache: &r.MultiRepoCache, } } -func (RootResolver) Repository() graph.RepositoryResolver { - return &repoResolver{} +func (r RootResolver) Repository() graph.RepositoryResolver { + return &repoResolver{r.cfg} } func (RootResolver) Bug() graph.BugResolver { @@ -50,7 +56,7 @@ func (RootResolver) Label() graph.LabelResolver { return &labelResolver{} } -func (r RootResolver) Identity() graph.IdentityResolver { +func (RootResolver) Identity() graph.IdentityResolver { return &identityResolver{} } |