From c55d6aa9b884fb5e798f10c905b19c1bcb0ea74f Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 27 Feb 2023 19:16:49 +0200 Subject: [PATCH 1/6] Hide `js-sys` behind `js` feature --- juniper/Cargo.toml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/juniper/Cargo.toml b/juniper/Cargo.toml index 5a017b14b..d1e35e43a 100644 --- a/juniper/Cargo.toml +++ b/juniper/Cargo.toml @@ -31,11 +31,19 @@ default = [ "url", "uuid", ] +bigdecimal = ["dep:bigdecimal"] +bson = ["dep:bson"] +chrono = ["dep:chrono"] chrono-clock = ["chrono", "chrono/clock"] chrono-tz = ["dep:chrono-tz", "dep:regex"] -expose-test-schema = ["anyhow", "serde_json"] +expose-test-schema = ["dep:anyhow", "dep:serde_json"] graphql-parser = ["dep:graphql-parser", "dep:void"] +js = ["chrono?/wasmbind", "time?/wasm-bindgen", "uuid?/js"] +rust_decimal = ["dep:rust_decimal"] schema-language = ["graphql-parser"] +time = ["dep:time"] +url = ["dep:url"] +uuid = ["dep:uuid"] [dependencies] anyhow = { version = "1.0.47", default-features = false, optional = true } @@ -57,17 +65,14 @@ smartstring = "1.0" static_assertions = "1.1" time = { version = "0.3", features = ["formatting", "macros", "parsing"], optional = true } url = { version = "2.0", optional = true } -uuid = { version = "1.0", default-features = false, optional = true } +uuid = { version = "1.3", default-features = false, optional = true } # Fixes for MSRV check. # TODO: Try remove on upgrade of `chrono-tz` crate. regex = { version = "1.6", default-features = false, optional = true } -# TODO: Remove on upgrade to 4.0.1 version of `graphql-parser`. +# TODO: Remove on upgrade to 0.4.1 version of `graphql-parser`. void = { version = "1.0.2", optional = true } -[target.'cfg(target_arch = "wasm32")'.dependencies] -getrandom = { version = "0.2", features = ["js"] } - [dev-dependencies] bencher = "0.1.2" chrono = { version = "0.4.20", features = ["alloc"], default-features = false } From 1ba9bf69323ba0aa4d63e26d39428a719741e9d1 Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 27 Feb 2023 19:26:39 +0200 Subject: [PATCH 2/6] Check on CI --- .github/workflows/ci.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 832602595..a5f9bcd1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -280,21 +280,31 @@ jobs: fail-fast: false matrix: crate: - - juniper_codegen - juniper + target: + - wasm32-unknown-unknown + - wasm32-wasi + feature: + - toolchain: - stable - beta - nightly + include: + - target: wasm32-unknown-unknown + feature: js runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@v1 with: toolchain: ${{ matrix.toolchain }} - target: wasm32-unknown-unknown + target: ${{ matrix.target }} - - run: cargo check --target wasm32-unknown-unknown -p ${{ matrix.crate }} + - run: cargo check --target ${{ matrix.target }} -p ${{ matrix.crate }} + ${{ matrix.feature != '' + && format('--features {0}', matrix.feature) + || '' }} From a7c5753119ea1ed56a7f1ea6fc819275d0019d30 Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 27 Feb 2023 19:40:05 +0200 Subject: [PATCH 3/6] Fix CI --- .github/workflows/ci.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5f9bcd1b..8615b4c5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,7 +125,6 @@ jobs: - { feature: graphql-parser, crate: juniper } - { feature: rust_decimal, crate: juniper } - { feature: schema-language, crate: juniper } - - { feature: serde_json, crate: juniper } - { feature: time, crate: juniper } - { feature: url, crate: juniper } - { feature: uuid, crate: juniper } @@ -284,15 +283,10 @@ jobs: target: - wasm32-unknown-unknown - wasm32-wasi - feature: - - toolchain: - stable - beta - nightly - include: - - target: wasm32-unknown-unknown - feature: js runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -302,9 +296,10 @@ jobs: target: ${{ matrix.target }} - run: cargo check --target ${{ matrix.target }} -p ${{ matrix.crate }} - ${{ matrix.feature != '' - && format('--features {0}', matrix.feature) - || '' }} + + - run: cargo check --target ${{ matrix.target }} -p ${{ matrix.crate }} + --features js + if: ${{ matrix.target == 'wasm32-unknown-unknown' }} From 68c2089f20f5f1f592dbda4c006c785ae07a8859 Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 27 Feb 2023 20:09:47 +0200 Subject: [PATCH 4/6] Fix --- .github/workflows/ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8615b4c5a..9376108d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -296,10 +296,9 @@ jobs: target: ${{ matrix.target }} - run: cargo check --target ${{ matrix.target }} -p ${{ matrix.crate }} - - - run: cargo check --target ${{ matrix.target }} -p ${{ matrix.crate }} - --features js - if: ${{ matrix.target == 'wasm32-unknown-unknown' }} + ${{ matrix.target == 'wasm32-unknown-unknown' + && '--feature js' + || '' }} From ef52a97dbf171d3805ecf2f2ed825b7b1ccb7e2a Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 27 Feb 2023 21:30:02 +0200 Subject: [PATCH 5/6] Mention in CHANGELOG --- juniper/CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/juniper/CHANGELOG.md b/juniper/CHANGELOG.md index fa547fddb..1a16e5707 100644 --- a/juniper/CHANGELOG.md +++ b/juniper/CHANGELOG.md @@ -61,6 +61,7 @@ All user visible changes to `juniper` crate will be documented in this file. Thi - `#[derive(GraphQLInterface)]` macro allowing using structs as GraphQL interfaces. ([#1026]) - [`bigdecimal` crate] integration behind `bigdecimal` [Cargo feature]. ([#1060]) - [`rust_decimal` crate] integration behind `rust_decimal` [Cargo feature]. ([#1060]) +- `js` [Cargo feature] enabling `js-sys` and `wasm-bindgen` support for `wasm32-unknown-unknown` target. ([#1118], [#1147]) ### Changed @@ -112,7 +113,9 @@ All user visible changes to `juniper` crate will be documented in this file. Thi [#1081]: /../../pull/1081 [#1085]: /../../issues/1085 [#1086]: /../../pull/1086 -[#1114]: /../../pull/1119 +[#1118]: /../../issues/1118 +[#1119]: /../../pull/1119 +[#1147]: /../../pull/1147 [ba1ed85b]: /../../commit/ba1ed85b3c3dd77fbae7baf6bc4e693321a94083 [CVE-2022-31173]: /../../security/advisories/GHSA-4rx6-g5vg-5f3j From 84f9ad53fb67681f1f51435c26a5b72b349a6d35 Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 27 Feb 2023 21:48:01 +0200 Subject: [PATCH 6/6] Fix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9376108d0..df18e58d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -297,7 +297,7 @@ jobs: - run: cargo check --target ${{ matrix.target }} -p ${{ matrix.crate }} ${{ matrix.target == 'wasm32-unknown-unknown' - && '--feature js' + && '--features js' || '' }}