Azure / data-api-builder

Data API builder provides modern REST and GraphQL endpoints to your Azure Databases and on-prem stores.
https://aka.ms/dab/docs
MIT License
787 stars 142 forks source link

Add a new CLI command to update values of the runtime section of the config #2243

Closed abhishekkumams closed 2 weeks ago

abhishekkumams commented 3 weeks ago

Background

Currently, the properties in the runtime section of the config file are only setup once, and the values are specified with the dab init command.

Problem

As we add new properties in the runtime section, the init command is growing fast and becoming more complex. Furthermore, the CLI currently does not support updating these properties post-initialization. This means that if a user wants to change a property in the runtime section after running the init command, they have to manually edit the config file. This process is not only inconvenient but also prone to errors, especially for users who are not familiar with the JSON syntax or the structure of the config file.

Moreover, re-initializing the config just to update a single property is not a practical solution. It's a time-consuming process that requires the user to re-enter all the configuration details, even if they only want to change one property. This can be particularly frustrating for users who have a complex configuration setup.

This lack of support for updating the runtime properties post-initialization is a significant limitation of the current CLI. It makes the process of managing and updating the configuration more difficult and less flexible than it needs to be. This can be a barrier to efficient usage and can negatively impact the user experience.

Proposal

There are 3 major parts of our config file in high-level : data-source,runtime,entity. data-source doesn't require change often and is usually an initialization section. For entities, we already have add and update command. So, I propose to add a new CLI command for updating just the runtime section of the config. This is how our runtime section of the config file looks like:

"runtime": {
    "rest": {
      "enabled": true,
      "path": "/api",
      "request-body-strict": true
    },
    "graphql": {
      "enabled": true,
      "path": "/graphql",
      "allow-introspection": true
    },
    "host": {
      "cors": {
        "origins": [
          "http://localhost:5000"
        ],
        "allow-credentials": false
      },
      "authentication": {
        "provider": "StaticWebApps"
      },
      "mode": "development"
    }
  }

Now, during initialization our runtime section will be setup with the user provided value or default values. But later using the below command they can be updated.

dab update-runtime [options]

Available options

it will have all the options to edit the runtime section of the config. Options Option Required Default Value Value Required Value Type Description
--host-mode ❌ No production ✔️ Yes string Specify the Host mode - development or production
--cors-origin ❌ No "" ✔️ Yes string Specify the list of allowed origins.
--auth.provider ❌ No StaticWebApps ✔️ Yes string Specify the Identity Provider.
--rest.path ❌ No /api ✔️ Yes string Specify the REST endpoint's prefix.
--rest.disabled ❌ No false ❌ No bool Disables REST endpoint for all entities.
--rest.enabled ❌ No true ✔️ Yes bool Enables REST endpoint for all entities.
--rest.request-body-strict ❌ No true ✔️ Yes bool Doesn't allow extraneous fields in request body.
--graphql.path ❌ No /graphql ✔️ Yes string Specify the GraphQL endpoint's prefix.
--graphql.disabled ❌ No false ❌ No bool Disables GraphQL endpoint for all entities.
--graphql.enabled ❌ No true ✔️ Yes bool Enables GraphQL endpoint for all entities.
--graphql.multiple-create.enabled ❌ No false ✔️ Yes bool Enables multiple create functionality in GraphQL.
--auth.audience ❌ No ✔️ Yes string Identifies the recipients that the Json Web Token (JWT) is intended for.
--auth.issuer ❌ No ✔️ Yes string Specify the party that issued the JWT token.
-c,--config ❌ No dab-config.json ✔️ Yes string Path to config file.
JerryNixon commented 3 weeks ago

I think dab runtime is sufficient, update-runtime is wordy for no reason.

JerryNixon commented 3 weeks ago

This needs to include caching and also telemetry even though telemetry is elsewhere in the CLI, we can remove that from Docs and let this be the primary point for runtime in the CLI.

JerryNixon commented 3 weeks ago

Related #2251