Relay Modern Tools for Scala.js Folks

There are three parts to this.

  • Relay Compiler Language for SJS - relay-compiler-language-scalajs details
  • Sbt plugin - addSbtPlugin("com.dispalt.relay" % "sbt-relay-compiler" % "<version>") which handles code generation sbt hooks
  • Scala.js runtime - "com.dispalt.relay" %%% "relay-macro" % "<version>" which handles the runtime, which is very small (intentionally).



  • Simplified the js code considerably by using the language hooks within the relay-compiler. There is a couple changes that make this a non-straightforward migration
    • Naming is more important now, some things accepted might not work now.
    • @scalajs directive is needed schema-side,
  • Upgraded to relay 2.0
  • Upgraded to use scalajs-bundler in the generate code step, which makes the whole process much simpler from an install standpoint.
  • Supports persisted queries, you have to wire everything up yourself though.


  • Upgrade relay to 1.6.2, most of the changes seem import related
  • Generate a def newInput(args...): MutationInputType = ... for all mutations, making it a little easier.


  • Add ability to mix in traits with scalarFields so if value was a string { value @scalajs(extends:"Foo") } The trait would have a member val value: String with Foo


  • Added support for @scalajs(useNulls: boolean) that gives you finer grained access to using A | Null


  • Added support to support .gql files in any directory from baseDirectory.value so while it looks over more files it can support alternate locations now.


  • Relay 1.5.0 compiler support, nothing extra came of that minus some code changes.
  • Add option for --useNulls that specifies using a union with Null type for optional fields.
  • Add option for --verbose to increase verbosity
  • Make @scalajs(extends: string) work for more cases (inline frags, linked fields, and frag defs)


  • Actually works against 1.4.1 with everything I can test.


  • Mutations and Queries now are fully typed input and output
  • Published for npm as well. I haven't run across a query that can't compile. however I don't use some of the advanced features.


  • published for sbt 1


  • Manually publish for bintray as follow publishSigned from sbt-relay-compiler then bintrayRelease
  • Sonatype releasing seems to not be automatic anymore. you should be able to use sonatypeReleaseAll after publishSigned