-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/hasura config #4
Conversation
Added some more stuff to the hasura metadata structs that would get lost on metadata replace otherwise (table customisations, rest endpoints). Also opens up the possibility to do camel casing on tables and fields. Please note this commit: https://github.com/tz1and/metadata/commit/9db1e2b0b6c1cba3ca5962a364ff018d8dc0ae9c |
Also added a way to run arbitrary hasura metadata customisations. Was wondering if I should include in this PR. Now I have. Please see the related commit to the metadata indexer here: https://github.com/tz1and/metadata/commit/0724746ed388710738b72dfb5b517a7259208465 It's definitely very useful to have. :) |
Ok, I understood what do you wanted to do =) Firstly, creating Secondly, if you want to decode a JSON field which can be one of multiple types (like type DatabaseUrl string
type DatabaseUrlFromEnv struct {
FromEnv string `json:"from_env"`
}
func (d *DatabaseUrl) UnmarshalJSON(data []byte) error {
type buf DatabaseUrl
if err := json.Unmarshal(data, (*buf)(d)); err == nil {
return nil
}
var val DatabaseUrlFromEnv
if err := json.Unmarshal(data, &val); err == nil {
*d = DatabaseUrl(val.FromEnv)
return nil
}
// process PGConnectionParameters here
return nil
}
type A struct {
// some fields here
DatabaseUrl DatabaseUrl `json:"database_url"`
// some fields here
} But generally I think your code should work, the above is my suggestion to your PR so that we can merge it with minimum refactoring afterwards. |
Ok, will make that change!
I think it's not needed as Thanks! |
No, I think it's not required. |
to make sure Load() works as intended.
Also, thanks for letting me know how to properly decode multiple types. Good to know. I changed the I also added a call to |
Heya,
alongside the PR I made to dipdup, to allow multiple souces in a hasura instance, here's my PR for fixing/improving the hasura metadata configuration.
It includes:
pg_add_source
) config entry.Probably, there's quite a lot more to improve, but this will do for my use case (hopefully).
Please note that you'll also need this commit from https://github.com/tz1and/metadata/commit/f1af98a396161aa287b3bb0281be2be8118d9a79
Thanks!