hasura / hasura/graphql-engine

idempotent metadata api

Open
#3,959 7 comments 5 reactions 0 assignees View on GitHub
c/server p/longterm
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

Hi,

I think some metadata APIs are good to be treated idempotent.

For instance, `add_computed_field` responds `400 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

```js
if (
!(
err.response.status === 400 &&
err.response.data.code === "already-exists"
)
) {
// ...
}
```

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.