Skip to content

Commit 1b7297d

Browse files
committed
add custom hasura configurations
1 parent cb3a4b7 commit 1b7297d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

hasura/api.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ func (api *API) TrackTable(ctx context.Context, name string, source string) erro
183183
return api.post(ctx, "/v1/metadata", nil, req, nil)
184184
}
185185

186+
// CustomConfiguration
187+
func (api *API) CustomConfiguration(ctx context.Context, conf interface{}) error {
188+
return api.post(ctx, "/v1/metadata", nil, conf, nil)
189+
}
190+
186191
// CreateSelectPermissions - A select permission is used to restrict access to only the specified columns and rows.
187192
func (api *API) CreateSelectPermissions(ctx context.Context, table, source string, role string, perm Permission) error {
188193
req := request{

hasura/hasura.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func checkHealth(ctx context.Context, api *API) {
4141
}
4242

4343
// Create - creates hasura models
44-
func Create(ctx context.Context, hasura *config.Hasura, cfg config.Database, views []string, models ...interface{}) error {
44+
func Create(ctx context.Context, hasura *config.Hasura, cfg config.Database, views []string, custom []interface{}, models ...interface{}) error {
4545
if hasura == nil {
4646
return nil
4747
}
@@ -129,6 +129,13 @@ func Create(ctx context.Context, hasura *config.Hasura, cfg config.Database, vie
129129
}
130130
}
131131

132+
log.Info().Msg("Running custom configurations...")
133+
for _, conf := range custom {
134+
if err := api.CustomConfiguration(ctx, conf); err != nil {
135+
log.Warn().Err(err).Msg("")
136+
}
137+
}
138+
132139
return nil
133140
}
134141

0 commit comments

Comments
 (0)