-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename schema fields and add a jsonschema generation and ref on init (#…
…361) ### What This PR does the following: 1. It renames a few fields in the configuration: - `configureOptions` -> `introspectionOptions` - `mutationsVersion` moved from `configureOptions` to the top-level - connection uri, pool settings and isolation level are now nested under "connectionSettings" - Native queries use a new `ReadonlyColumnInfo` type instead of `ColumnInfo` type for arguments and column. ReadonlyColumnInfo does not contain default, identity and generated information which we don't want to appear in autocomplete for native queries. 2. It generates a `schema.jsonschema` file on cli `initialize` command next to the `configuration.json` file 3. It adds the `$schema` field to the configuration, referencing the generated `schema.jsonschema` file. The purpose of (2) and (3) is to provide auto-complete features when editing the configuration in vscode (demo soon). ![Screenshot from 2024-03-12 16-56-07](https://github.com/hasura/ndc-postgres/assets/8547573/f4149d91-041a-4571-b387-0f873cc9ad21)
- Loading branch information
Gil Mizrahi
authored
Mar 13, 2024
1 parent
5e4026b
commit ebb7b53
Showing
27 changed files
with
1,715 additions
and
261 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//! Database connection settings. | ||
use crate::values::{ConnectionUri, IsolationLevel, PoolSettings, Secret}; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub const DEFAULT_CONNECTION_URI_VARIABLE: &str = "CONNECTION_URI"; | ||
|
||
/// Database connection settings. | ||
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct DatabaseConnectionSettings { | ||
/// Connection string for a Postgres-compatible database. | ||
pub connection_uri: ConnectionUri, | ||
/// Connection pool settings. | ||
#[serde(default)] | ||
pub pool_settings: PoolSettings, | ||
/// Query isolation level. | ||
#[serde(default)] | ||
pub isolation_level: IsolationLevel, | ||
} | ||
|
||
impl DatabaseConnectionSettings { | ||
pub fn empty() -> Self { | ||
Self { | ||
connection_uri: ConnectionUri(Secret::FromEnvironment { | ||
variable: DEFAULT_CONNECTION_URI_VARIABLE.into(), | ||
}), | ||
pool_settings: PoolSettings::default(), | ||
isolation_level: IsolationLevel::default(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.