Open jjangga0214 opened 4 years ago
This is something I've had trouble handling as well. All track APIs should be idempotent.
Turns out with v2 metadata workflow (https://github.com/hasura/graphql-engine/pull/3859) this might not be an issue because the full metadata would be applied.
It's still relevant for projects using the metadata API as a way to configure Hasura. e.g. the console
I have a small library (https://github.com/beepsoft/hasuraconf), which generates Hasura metadata API calls based on JPA and other annotations in Java, so this idempotent behaviour here would be really helpful.
Running into this issue while sending off 'add_remote_schema' requests to the query API in k8s environment where I was assuming an already existing remote schema would not give out a HTTP 400 error code.
@tirumaraiselvan I've seen in the last community call that there's a lot going on with Hasura metadata handling.
Is this idempotent metadata api fix still on the roadmap?
Solving this would help with all the headaches we still have with managing many remote schemas in Hasura.
@tirumaraiselvan Any news on this issue? Thanks!
Hi,
I think some metadata APIs are good to be treated idempotent.
For instance,
add_computed_field
responds400 already-exists
error, if I try to add an existing computed field. I understand this is to prevent mistakenly overriding the existing fields.To ignore this, currently, one should add explicit error handling, something like
However, for a practical point of view, considering it as an idempotent action would be a little more convenient. For one of examples, someone might want to run
add_computed_field
as migration phase(including metadata API calling, not limited to Hasura's migration feature) to make it simpler.If there are many different Hasura instances on different environments, he or she might just not want to think about if "this hasura" or "that hasura" already has the computed field or not. So one might want to treat it more like declarative configuration (e.g. k8s manifest).
If this makes sense, I want to hear how others think about it.
Thanks.