graphql-rust / juniper

GraphQL server library for Rust
Other
5.72k stars 425 forks source link

Support non-browser WASM #1147

Closed tyranron closed 1 year ago

tyranron commented 1 year ago

Resolved #1118

Synopsis

From #1118:

When compiling projects targeting wasm32-unknown-unknown, dependencies on wbindgen are emitted in the wasm file.

(import "__wbindgen_placeholder__" "__wbindgen_describe" (func $_ZN12wasm_bindgen19__wbindgen_describe17hd0bb5db14a487f56E (type $t0)))
(import "__wbindgen_placeholder__" "__wbindgen_throw" (func $_ZN12wasm_bindgen16__wbindgen_throw17h1f7ec3f048b25bd4E (type $t10)))
(import "__wbindgen_externref_xform__" "__wbindgen_externref_table_grow" (func $_ZN12wasm_bindgen9externref31__wbindgen_externref_table_grow17h23c6ebadcc732f10E (type $t1)))
(import "__wbindgen_externref_xform__" "__wbindgen_externref_table_set_null" (func $_ZN12wasm_bindgen9externref35__wbindgen_externref_table_set_null17h8f133612ea24d34dE (type $t0)))

In a non-browser environment, these dependencies will not be supported. A non-browser environment is a substantial use case for a graphql server (perhaps more than a browser environment), and should be supported.

Solution

Enable support for js-sys behind a js Cargo feature only.