kesne / HostyHosting

A platform to easily manage and deploy your applications.
https://www.hostyhosting.com/
Other
92 stars 16 forks source link

Idea: Complex input types for mutations #76

Closed kesne closed 4 years ago

kesne commented 4 years ago

I wonder if we can improve our mutation APIs a bit by making our mutation query flatter, and leverage a more dynamic input type. I'm still not convinced that this is a good idea, and it also means our return would likely be a union, which seems like a disaster potentially. That said, it could look something like this:

Before:

mutation {
  application(id: 1) {
    component(id: 2) {
      addSecret(key: "foo", value: "bar") { id }
    }
  }
}

After:

mutation {
  application(id: 1) {
    create(
      input: {
        "component": {
          "secret": {
            "key": "foo",
            "value": "bar"
          }
        }
      }
    ) { id }
  }
}
kesne commented 4 years ago

no