Skip to content

Commit

Permalink
Support non-browser WASM (#1147, #1118)
Browse files Browse the repository at this point in the history
- gate `js-sys` and `wasm-bindgen` behind `js` Cargo feature
  • Loading branch information
tyranron authored Feb 28, 2023
1 parent b84621c commit 7e5c881
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -280,8 +279,10 @@ jobs:
fail-fast: false
matrix:
crate:
- juniper_codegen
- juniper
target:
- wasm32-unknown-unknown
- wasm32-wasi
toolchain:
- stable
- beta
Expand All @@ -292,9 +293,12 @@ jobs:
- 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.target == 'wasm32-unknown-unknown'
&& '--features js'
|| '' }}



Expand Down
5 changes: 4 additions & 1 deletion juniper/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
17 changes: 11 additions & 6 deletions juniper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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 }
Expand Down

0 comments on commit 7e5c881

Please sign in to comment.