Registry / http-networking / relay-compiler-language-scalajs

relay-compiler-language-scalajs

JSON →
library0.41.0jsnpmunverified

A Relay compiler language plugin that generates Scala.js bindings (js.native traits) instead of Flow types for GraphQL-driven Scala.js applications. Compatible with Relay 11.0.2, graphql ^15.4.0, and relay-runtime ^11.0.2. The plugin outputs compiled queries as Scala.js native traits, supports custom output via @scalajs directives (extends, useNulls), and uses artifactDirectory for flat package generation. Release cadence is irregular with minor version bumps for dependency updates. Differentiator: enables Relay for Scala.js/React.js integration, not maintained by the core Relay team.

npm install relay-compiler-language-scalajs
INSTALL
IMPORT
SIG · RELAY-COMPILER-LAN
R
relay-compiler-language-scalajs
http-networkingjavascriptv0.41.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

relay-compiler
import 'relay-compiler' (see docs)
No direct JS import; used via CLI
This is a compiler language plugin; no JavaScript import. Configure via relay-compiler --language scalajs.
@scalajs
Used as GraphQL directive in .graphql files
Not a JavaScript import
Use as @scalajs(extends: String) or @scalajs(useNulls: Boolean) on GraphQL fragments/fields.
relay-runtime
npm install relay-runtime
Missing peer dep
Required at runtime for Relay queries; version ^11.0.2.

Installs required packages and shows relay-compiler invocation to generate Scala.js bindings.

// 1. Install dependencies npm install --save-dev relay-compiler@11.0.2 relay-compiler-language-scalajs graphql@^15.4.0 npm install relay-runtime@^11.0.2 // 2. Run relay-compiler with scalajs language // ./node_modules/.bin/relay-compiler --language scalajs --src ./src --schema ./schema.graphql --artifactDirectory ./src/__generated__ // 3. Generated Scala.js file (example: src/__generated__/MyFragment.scala) @js.native trait MyFragment_data extends js.Object { val id: String = js.native val name: String | Null = js.native }
Debug
Known issues
gotchaRequires exact Relay version 11.0.2; other versions may break.
fix
Ensure relay-compiler version is pinned to 11.0.2.
affects: >=0.32.0
gotchaUses artifactDirectory flat layout; all generated files in one directory.
fix
Configure artifactDirectory to a dedicated output directory, not mixed with sources.
affects: >=0.32.0
deprecatedThe @scalajs(extends) directive requires manual verification of parent class.
fix
Ensure the extended class exists in Scala.js scope.
affects: >=0.32.0
gotchagraphql peer dependency must be ^15.4.0, not newer GraphQL versions.
fix
Use GraphQL 15.4.x or compatible.
affects: >=0.32.0
Errors
Common errors & fixes
Error: Cannot find module 'relay-compiler-language-scalajs'
Missing npm install of the package
fix
Run: npm install --save-dev relay-compiler-language-scalajs
Error: The language 'scalajs' is not supported.
relay-compiler version mismatch or missing plugin
fix
Ensure relay-compiler@11.0.2 is installed and package is in node_modules.
Error: No schema found at --schema path
Invalid or missing GraphQL schema file
fix
Provide valid .graphql schema path via --schema.
Error: Could not parse GraphQL file: unexpected directive
Using @scalajs on unsupported GraphQL elements
fix
Only use @scalajs on fragments, fields, or inline fragments.
Upgrade
Version history
0.41.0latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency for GraphQL schema parsing
relay-compilerrequiredPeer dependency; version 11.0.2 required
relay-runtimerequiredPeer dependency for Relay runtime types
Agent activity
6 hits · last 30 days
node
6
Resources
relay-compiler-language-scalajs — npm install relay-compiler-language-scalajs · libregistry