added list buckets query
This commit is contained in:
@@ -100,6 +100,21 @@ func GraphqlSchema() (graphql.Schema, error) {
|
||||
return auth, nil
|
||||
},
|
||||
},
|
||||
"buckets": &graphql.Field{
|
||||
Name: "buckets",
|
||||
Type: graphql.NewNonNull(graphql.NewList(graphql.String)),
|
||||
Description: "List available buckets",
|
||||
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
|
||||
if !helper.IsAuthenticated(p.Context) {
|
||||
return nil, s3errors.ErrNotAuthenticated
|
||||
}
|
||||
|
||||
loader := p.Context.Value("loader").(map[string]*dataloader.Loader)
|
||||
// The only reason we use a dataloader with a empty key is that we want to cache the result
|
||||
thunk := loader["listBuckets"].Load(p.Context, dataloader.StringKey(""))
|
||||
return thunk()
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
mutationFields := graphql.Fields{
|
||||
|
||||
Reference in New Issue
Block a user