{"library":"scala-relay-compiler","title":"Scala Relay Compiler","description":"A build tool that generates Scala.js bindings from GraphQL schemas and Relay-compiled queries. It replaces the default Flow type generation of the relay-compiler with Scala.js native traits, enabling type-safe GraphQL queries in Scala.js applications. Current version 0.12.4 is experimental and supports Relay specifications. It uses a regex-based approach to extract GraphQL operations from Scala source files annotated with @gql. Differentiating from similar tools like Apollo Scala.js, it integrates closely with the Relay ecosystem and supports deep hierarchical graph structures, spreading, and custom scalajs annotations.","language":"javascript","status":"active","last_verified":"Fri May 01","install":{"commands":["npm install scala-relay-compiler"],"cli":null},"imports":["npm install scala-relay-compiler","import relay.graphql.GenericGraphQLTaggedNode","@gql(\"\"\"...\"\"\")"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// 1. Install relay-compiler and scala-relay-compiler\nnpm install --save-dev relay-compiler scala-relay-compiler\n\n// 2. Create a GraphQL schema file (schema.graphql)\n// 3. Create Scala source files with @gql annotations\n// Example: src/main/scala/com/example/Foo.scala\npackage com.example\n\nobject Foo {\n  val query = @gql(\"\"\"\n  query ExampleQuery {\n    dictionary {\n      ...DictionaryComponent_word\n    }\n  }\n  \"\"\")\n\n  val fragment = @gql(\"\"\"\n  fragment DictionaryComponent_word on Word {\n    id\n    text\n  }\n  \"\"\")\n}\n\n// 4. Run relay-compiler to generate JSON artifacts\nnpx relay-compiler --schema schema.graphql --src src/ --language javascript --artifactDirectory relay-artifacts/\n\n// 5. Run scala-relay-compiler to generate Scala.js bindings\nnpx scala-relay-compiler --src src/ --schema schema.graphql --out target/generated/\n\n// 6. Include generated files in your Scala.js project build","lang":"javascript","description":"Complete workflow to set up scala-relay-compiler with a GraphQL schema and Scala source files.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}