Skip to content

Commit

Permalink
chore(schema-engine): get rid of toml -> Rust generation in `json…
Browse files Browse the repository at this point in the history
…-rpc-api-build`, which is now compatible with `wasm32-unknown-unknown` (#5224)

This PR:
- Closes
[ORM-778](https://linear.app/prisma-company/issue/ORM-778/get-rid-of-toml-rust-generation-in-json-rpc-api-build-enable-wasm)
- Gets rid of `toml` -> `Rust` generation in `json-rpc-api-build`. Toml
definitions are substituted with equivalent Rust struct/enum
declarations, avoiding all the previous build-time shenanigans.
- You can see the previous expanded macro in
b1efb11.
- Renames `json-rpc-api-build` into `json-rpc-api`
- Enables `wasm32-unknown-unknown` usage of `json-rpc-api`

/integration

---------

Co-authored-by: jkomyno <[email protected]>
  • Loading branch information
jkomyno and jkomyno authored Mar 5, 2025
1 parent ebe9274 commit 56bd63f
Show file tree
Hide file tree
Showing 36 changed files with 735 additions and 1,135 deletions.
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ members = [
"schema-engine/core",
"schema-engine/connectors/*",
"schema-engine/datamodel-renderer",
"schema-engine/json-rpc-api-build",
"schema-engine/json-rpc-api",
"schema-engine/mongodb-schema-describer",
"schema-engine/sql-migration-tests",
"schema-engine/sql-introspection-tests",
Expand Down
4 changes: 1 addition & 3 deletions schema-engine/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ user-facing-errors = { workspace = true, features = [
"quaint",
] }

json-rpc = { path = "../json-rpc-api", package = "json-rpc-api" }
async-trait.workspace = true
chrono.workspace = true
enumflags2.workspace = true
Expand All @@ -28,8 +29,5 @@ tracing-subscriber.workspace = true
tracing-futures.workspace = true
url.workspace = true

[build-dependencies]
json-rpc-api-build = { path = "../json-rpc-api-build" }

[features]
vendored-openssl = ["sql-schema-connector/vendored-openssl"]
7 changes: 0 additions & 7 deletions schema-engine/core/build.rs

This file was deleted.

3 changes: 2 additions & 1 deletion schema-engine/core/src/api.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! The external facing programmatic API to the schema engine.
use crate::{commands, json_rpc::types::*, CoreResult};
use crate::{commands, CoreResult};
use json_rpc::types::*;

/// The programmatic, generic, fantastic schema engine API.
#[async_trait::async_trait]
Expand Down
2 changes: 1 addition & 1 deletion schema-engine/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//! The top-level library crate for the schema engine.
include!(concat!(env!("OUT_DIR"), "/methods.rs"));
pub use json_rpc;

// exposed for tests
#[doc(hidden)]
Expand Down
3 changes: 2 additions & 1 deletion schema-engine/core/src/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{json_rpc::method_names::*, CoreError, CoreResult, GenericApi};
use crate::{CoreError, CoreResult, GenericApi};
use json_rpc::method_names::*;
use jsonrpc_core::{types::error::Error as JsonRpcError, IoHandler, Params};
use psl::SourceFile;
use std::sync::Arc;
Expand Down
5 changes: 2 additions & 3 deletions schema-engine/core/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
//! Why this rather than using connectors directly? We must be able to use the schema engine
//! without a valid schema or database connection for commands like createDatabase and diff.
use crate::{
api::GenericApi, commands, json_rpc::types::*, parse_configuration_multi, CoreError, CoreResult, SchemaContainerExt,
};
use crate::{api::GenericApi, commands, parse_configuration_multi, CoreError, CoreResult, SchemaContainerExt};
use enumflags2::BitFlags;
use json_rpc::types::*;
use psl::{parser_database::SourceFile, PreviewFeature};
use schema_connector::{ConnectorError, ConnectorHost, IntrospectionResult, Namespaces, SchemaConnector};
use std::{
Expand Down
9 changes: 0 additions & 9 deletions schema-engine/json-rpc-api-build/Cargo.toml

This file was deleted.

10 changes: 0 additions & 10 deletions schema-engine/json-rpc-api-build/README.md

This file was deleted.

29 changes: 0 additions & 29 deletions schema-engine/json-rpc-api-build/methods/applyMigrations.toml

This file was deleted.

41 changes: 0 additions & 41 deletions schema-engine/json-rpc-api-build/methods/common.toml

This file was deleted.

12 changes: 0 additions & 12 deletions schema-engine/json-rpc-api-build/methods/createDatabase.toml

This file was deleted.

46 changes: 0 additions & 46 deletions schema-engine/json-rpc-api-build/methods/createMigration.toml

This file was deleted.

25 changes: 0 additions & 25 deletions schema-engine/json-rpc-api-build/methods/dbExecute.toml

This file was deleted.

8 changes: 0 additions & 8 deletions schema-engine/json-rpc-api-build/methods/debugPanic.toml

This file was deleted.

39 changes: 0 additions & 39 deletions schema-engine/json-rpc-api-build/methods/devDiagnostic.toml

This file was deleted.

This file was deleted.

Loading

0 comments on commit 56bd63f

Please sign in to comment.