├── .editorconfig ├── .github └── workflows │ └── scala.yml ├── .gitignore ├── .scalafmt.conf ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── build.sbt ├── project ├── Build.scala ├── Dependencies.scala ├── PluginsAccessor.scala ├── ReleaseCustom.scala ├── build.properties └── plugins.sbt ├── sbt-scala-relay └── src │ ├── main │ └── scala │ │ └── com │ │ └── goodcover │ │ └── relay │ │ ├── Commands.scala │ │ ├── GraphQLConverter.scala │ │ ├── GraphQLExtractor.scala │ │ ├── GraphQLSchema.scala │ │ ├── GraphQLText.scala │ │ ├── GraphQLWrapper.scala │ │ ├── RelayCompiler.scala │ │ ├── ScalaRelayBasePlugin.scala │ │ ├── ScalaRelayPlugin.scala │ │ ├── codegen │ │ ├── DefinitionWriter.scala │ │ ├── Directives.scala │ │ ├── DocumentConverter.scala │ │ ├── ExecutableDefinitionWriter.scala │ │ ├── Fields.scala │ │ ├── FragmentWriter.scala │ │ ├── InputWriter.scala │ │ ├── MutationWriter.scala │ │ ├── OperationInputWriter.scala │ │ ├── OperationWriter.scala │ │ ├── QueryWriter.scala │ │ ├── ScalaWriter.scala │ │ ├── Selections.scala │ │ ├── SubscriptionWriter.scala │ │ ├── TypeConverter.scala │ │ └── package.scala │ │ └── package.scala │ └── sbt-test │ ├── relay-compiler │ ├── basic │ │ ├── README.md │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ ├── frags │ │ │ │ │ └── Test.gql │ │ │ │ └── testschema.graphql │ │ │ │ └── scala │ │ │ │ └── example │ │ │ │ └── Main.scala │ │ └── test │ ├── basicpersist │ │ ├── README.md │ │ ├── build.sbt │ │ ├── expected │ │ │ ├── a.json │ │ │ └── b.json │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ ├── frags │ │ │ │ │ └── Test.gql │ │ │ │ └── testschema.graphql │ │ │ │ └── scala │ │ │ │ └── example │ │ │ │ ├── Main.scala │ │ │ │ └── Test.bak │ │ └── test │ ├── cache │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── replace-version.sh │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ ├── Test.graphql │ │ │ │ ├── Test2.graphql │ │ │ │ └── Test2.graphql.bak │ │ └── test │ ├── connection │ │ ├── build.sbt │ │ ├── expected │ │ │ └── Test_fragment.graphql.ts │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ ├── fragments │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ ├── frags │ │ │ │ │ └── Test.gql │ │ │ │ └── testschema.graphql │ │ │ │ └── scala │ │ │ │ └── example │ │ │ │ └── Main.scala │ │ └── test │ ├── multi-project │ │ ├── README.md │ │ ├── a │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── resources │ │ │ │ └── graphql │ │ │ │ │ └── StoryComponent.graphql │ │ │ │ └── scala │ │ │ │ └── example │ │ │ │ └── TaskComponent.scala │ │ ├── b │ │ │ ├── scalajs.webpack.config.js.template │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── scala │ │ │ │ └── example │ │ │ │ └── Main.scala │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── test │ │ └── testschema.graphql │ ├── refetchable │ │ ├── build.sbt │ │ ├── expected │ │ │ ├── Args.graphql.ts │ │ │ ├── ArgsOfSpread.graphql.ts │ │ │ ├── ImplicitNodeArgs.graphql.ts │ │ │ ├── NestedArgs.graphql.ts │ │ │ ├── NoArgs.graphql.ts │ │ │ ├── ObjectArgs.graphql.ts │ │ │ ├── Test_fragment.graphql.ts │ │ │ ├── Test_fragment2.graphql.ts │ │ │ ├── Test_fragment3.graphql.ts │ │ │ ├── Test_fragment4.graphql.ts │ │ │ ├── Test_fragment5.graphql.ts │ │ │ ├── Test_fragment6.graphql.ts │ │ │ ├── Test_viewer.graphql.ts │ │ │ └── ViewerQuery.graphql.ts │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ └── typescript │ │ ├── build.sbt │ │ ├── expected │ │ ├── TestListResponseQuery.graphql.ts │ │ ├── TestListVariableQuery.graphql.ts │ │ ├── TestMultipleVariablesQuery.graphql.ts │ │ ├── TestNestedObjectVariableQuery.graphql.ts │ │ ├── TestNoVariablesQuery.graphql.ts │ │ ├── TestObjectVariableQuery.graphql.ts │ │ ├── TestOptionalListVariableQuery.graphql.ts │ │ ├── TestOptionalObjectVariableQuery.graphql.ts │ │ ├── TestOptionalPrimitiveResponseQuery.graphql.ts │ │ ├── TestOptionalPrimitiveVariableQuery.graphql.ts │ │ ├── TestPrimitiveResponseQuery.graphql.ts │ │ └── TestPrimitiveVariableQuery.graphql.ts │ │ ├── project │ │ ├── build.properties │ │ └── plugins.sbt │ │ ├── src │ │ └── main │ │ │ └── resources │ │ │ └── graphql │ │ │ ├── Schema.graphqls │ │ │ └── Test.graphql │ │ └── test │ ├── relay-convert │ ├── alias │ │ ├── Test_node.expected.scala │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ ├── basic │ │ ├── TestMutation.expected.scala │ │ ├── TestQuery.expected.scala │ │ ├── TestSubscription.expected.scala │ │ ├── Test_fragment.expected.scala │ │ ├── Test_fragmentInterface.expected.scala │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ ├── cache │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── replace-version.sh │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ ├── Test.graphql │ │ │ │ ├── Test2.graphql │ │ │ │ └── Test2.graphql.bak │ │ └── test │ ├── collision │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ ├── Test.graphql │ │ │ │ └── Test2.graphql │ │ └── test │ ├── connection │ │ ├── build.sbt │ │ ├── expected │ │ │ └── Test_fragment.scala │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ ├── error-recovery │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ ├── Test.graphql │ │ │ │ └── Test.graphql.bak │ │ └── test │ ├── fragment-spread │ │ ├── TestMutation.expected.scala │ │ ├── TestQuery.expected.scala │ │ ├── TestSubscription.expected.scala │ │ ├── Test_viewer.expected.scala │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ ├── inline-directive │ │ ├── Test_fragment.expected.scala │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ ├── inline-fragment │ │ ├── TestQuery.expected.scala │ │ ├── Test_node.expected.scala │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ ├── mutation │ │ ├── build.sbt │ │ ├── expected │ │ │ ├── Input.scala │ │ │ ├── Nested.scala │ │ │ ├── TestListResponseMutation.scala │ │ │ ├── TestListVariableMutation.scala │ │ │ ├── TestMultipleVariablesMutation.scala │ │ │ ├── TestNestedObjectVariableMutation.scala │ │ │ ├── TestNoVariablesMutation.scala │ │ │ ├── TestObjectVariableMutation.scala │ │ │ ├── TestOptionalListVariableMutation.scala │ │ │ ├── TestOptionalObjectVariableMutation.scala │ │ │ ├── TestOptionalPrimitiveResponseMutation.scala │ │ │ ├── TestOptionalPrimitiveVariableMutation.scala │ │ │ ├── TestPrimitiveResponseMutation.scala │ │ │ └── TestPrimitiveVariableMutation.scala │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ ├── query │ │ ├── build.sbt │ │ ├── expected │ │ │ ├── Input.scala │ │ │ ├── Nested.scala │ │ │ ├── TestListResponseQuery.scala │ │ │ ├── TestListVariableQuery.scala │ │ │ ├── TestMultipleVariablesQuery.scala │ │ │ ├── TestNestedObjectVariableQuery.scala │ │ │ ├── TestNoVariablesQuery.scala │ │ │ ├── TestObjectVariableQuery.scala │ │ │ ├── TestOptionalListVariableQuery.scala │ │ │ ├── TestOptionalObjectVariableQuery.scala │ │ │ ├── TestOptionalPrimitiveResponseQuery.scala │ │ │ ├── TestOptionalPrimitiveVariableQuery.scala │ │ │ ├── TestPrimitiveResponseQuery.scala │ │ │ └── TestPrimitiveVariableQuery.scala │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ ├── refetchable │ │ ├── build.sbt │ │ ├── expected │ │ │ ├── Args.scala │ │ │ ├── ArgsOfSpread.scala │ │ │ ├── ImplicitNodeArgs.scala │ │ │ ├── NestedArgs.scala │ │ │ ├── NoArgs.scala │ │ │ ├── ObjectArgs.scala │ │ │ ├── Stuff.scala │ │ │ ├── Test_fragment.scala │ │ │ ├── Test_fragment2.scala │ │ │ ├── Test_fragment3.scala │ │ │ ├── Test_fragment4.scala │ │ │ ├── Test_fragment5.scala │ │ │ ├── Test_fragment6.scala │ │ │ ├── Test_viewer.scala │ │ │ ├── Thing.scala │ │ │ └── ViewerQuery.scala │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ ├── scalajs-directive-client-type │ │ ├── build.sbt │ │ ├── expected │ │ │ ├── ClientTypeInput.scala │ │ │ ├── ClientTypeNestedInput.scala │ │ │ ├── TestQuery.scala │ │ │ └── Test_fragment.scala │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ ├── scalajs-directive-extends │ │ ├── Test_fragment.expected.scala │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ ├── subscription │ │ ├── build.sbt │ │ ├── expected │ │ │ ├── Input.scala │ │ │ ├── Nested.scala │ │ │ ├── TestListResponseSubscription.scala │ │ │ ├── TestListVariableSubscription.scala │ │ │ ├── TestMultipleVariablesSubscription.scala │ │ │ ├── TestNestedObjectVariableSubscription.scala │ │ │ ├── TestNoVariablesSubscription.scala │ │ │ ├── TestObjectVariableSubscription.scala │ │ │ ├── TestOptionalListVariableSubscription.scala │ │ │ ├── TestOptionalObjectVariableSubscription.scala │ │ │ ├── TestOptionalPrimitiveResponseSubscription.scala │ │ │ ├── TestOptionalPrimitiveVariableSubscription.scala │ │ │ ├── TestPrimitiveResponseSubscription.scala │ │ │ └── TestPrimitiveVariableSubscription.scala │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── graphql │ │ │ │ ├── Schema.graphqls │ │ │ │ └── Test.graphql │ │ └── test │ └── type-mapping │ │ ├── build.sbt │ │ ├── expected │ │ ├── ClientTypeInput.scala │ │ ├── ClientTypeNestedInput.scala │ │ ├── TestQuery.scala │ │ └── Test_fragment.scala │ │ ├── project │ │ ├── build.properties │ │ └── plugins.sbt │ │ ├── src │ │ └── main │ │ │ └── resources │ │ │ └── graphql │ │ │ ├── Schema.graphqls │ │ │ └── Test.graphql │ │ └── test │ ├── relay-extract │ ├── basic │ │ ├── build.sbt │ │ ├── expected.template.graphql │ │ ├── make-expected.sh │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── src │ │ │ └── main │ │ │ │ └── scala │ │ │ │ └── example │ │ │ │ └── Test.scala │ │ └── test │ ├── cache │ │ ├── build.sbt │ │ ├── project │ │ │ ├── build.properties │ │ │ └── plugins.sbt │ │ ├── replace-version.sh │ │ ├── src │ │ │ └── main │ │ │ │ └── scala │ │ │ │ └── example │ │ │ │ ├── NoQuery.scala │ │ │ │ ├── Test.scala │ │ │ │ ├── Test2.scala │ │ │ │ └── Test2.scala.bak │ │ └── test │ └── collision │ │ ├── build.sbt │ │ ├── project │ │ ├── build.properties │ │ └── plugins.sbt │ │ ├── src │ │ └── main │ │ │ └── scala │ │ │ ├── example │ │ │ └── Test.scala │ │ │ └── example2 │ │ │ ├── Test.bak │ │ │ └── Test.scala │ │ └── test │ └── relay-wrap │ ├── argument-definitions │ ├── build.sbt │ ├── expected.js │ ├── project │ │ ├── build.properties │ │ └── plugins.sbt │ ├── src │ │ └── main │ │ │ └── resources │ │ │ └── graphql │ │ │ └── Test.graphql │ └── test │ ├── basic │ ├── build.sbt │ ├── expected.js │ ├── project │ │ ├── build.properties │ │ └── plugins.sbt │ ├── src │ │ └── main │ │ │ └── resources │ │ │ └── graphql │ │ │ └── Test.graphql │ └── test │ ├── cache │ ├── build.sbt │ ├── project │ │ ├── build.properties │ │ └── plugins.sbt │ ├── replace-version.sh │ ├── src │ │ └── main │ │ │ └── resources │ │ │ └── graphql │ │ │ ├── Test.graphql │ │ │ ├── Test2.graphql │ │ │ └── Test2.graphql.bak │ └── test │ └── collision │ ├── build.sbt │ ├── project │ ├── build.properties │ └── plugins.sbt │ ├── src │ └── main │ │ ├── resources │ │ └── graphql │ │ │ └── Test.graphql │ │ └── scala │ │ └── example │ │ ├── Test.bak │ │ └── Test.scala │ └── test ├── scala-relay-core └── src │ └── main │ ├── scala-2 │ ├── com │ │ └── goodcover │ │ │ └── relay │ │ │ └── UnionImplicits.scala │ └── relay │ │ └── generated │ │ └── package.scala │ └── scala │ └── com │ └── goodcover │ └── relay │ ├── FragmentRef.scala │ ├── Introspectable.scala │ ├── TaggedNode.scala │ ├── graphql.scala │ ├── hooks.scala │ └── package.scala ├── scala-relay-ijext └── src │ └── main │ └── scala │ └── com │ └── goodcover │ └── relay │ └── GraphQLGenInjector.scala ├── scala-relay-macros └── src │ └── main │ └── scala │ └── com │ └── goodcover │ └── relay │ └── macros.scala ├── scripts └── import-gpg.sh └── version.sbt /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | 11 | # Matches multiple files with brace expansion notation 12 | # Set default charset 13 | [*.{js,py}] 14 | charset = utf-8 15 | indent_style = space 16 | indent_size = 2 17 | 18 | # Tab indentation (no size specified) 19 | [Makefile] 20 | indent_style = tab 21 | 22 | # Indentation override for all JS under lib directory 23 | [src/**.js] 24 | indent_style = space 25 | indent_size = 2 26 | 27 | # Matches the exact files either package.json or .travis.yml 28 | [{package.json,.travis.yml}] 29 | indent_style = space 30 | indent_size = 2 31 | -------------------------------------------------------------------------------- /.github/workflows/scala.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | 6 | name: Scala CI 7 | 8 | on: 9 | push: 10 | branches: [ "master" ] 11 | pull_request: 12 | branches: [ "master" ] 13 | 14 | permissions: 15 | contents: write # this permission is needed to submit the dependency graph 16 | 17 | jobs: 18 | build: 19 | 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | - name: Set up JDK 11 25 | uses: actions/setup-java@v4 26 | with: 27 | java-version: '11' 28 | distribution: 'temurin' 29 | cache: 'sbt' 30 | # - name: import gpg 31 | # env: 32 | # PGP_SECRET: ${{ secrets.gpg_key_priv }} 33 | # PGP_PUBLIC: ${{ secrets.gpg_key_pub }} 34 | # run: scripts/import-gpg.sh 35 | - uses: actions/setup-node@v3 36 | with: 37 | node-version: 21 38 | - name: Setup sbt 39 | uses: sbt/setup-sbt@v1 40 | - name: Cache scala dependencies 41 | uses: coursier/cache-action@v6 42 | - name: Run tests 43 | run: sbt "all test scriptedAll" 44 | # Optional: This step uploads information to the GitHub dependency graph and unblocking Dependabot alerts for the repository 45 | - name: Upload dependency graph 46 | uses: scalacenter/sbt-dependency-submission@v2 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | __generated__ 3 | *.log 4 | out/ 5 | target/ 6 | .ensime 7 | .ensime_cache/ 8 | .idea/ 9 | 10 | # Metals 11 | .metals/ 12 | .bloop/ 13 | project/metals.sbt 14 | .bsp 15 | -------------------------------------------------------------------------------- /.scalafmt.conf: -------------------------------------------------------------------------------- 1 | // NEW STYLE. 2 | style = IntelliJ 3 | danglingParentheses = true 4 | version = "2.2.1" 5 | maxColumn = 120 6 | rewrite.rules = [SortImports, PreferCurlyFors, RedundantParens] 7 | project.git = true 8 | align = more 9 | runner.dialect = scala212 10 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | - call `release` to deploy everything, you'll need a GPG key, and Sonatype credentials handy 4 | - call `scala-relay-ijext/updateIntellij` 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This software is licensed under the Apache 2 license, quoted below. 2 | 3 | Copyright 2017 Dan Di Spaltro 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 | use this file except in compliance with the License. You may obtain a copy of 7 | the License at 8 | 9 | [http://www.apache.org/licenses/LICENSE-2.0] 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | License for the specific language governing permissions and limitations under 15 | the License. 16 | -------------------------------------------------------------------------------- /project/Build.scala: -------------------------------------------------------------------------------- 1 | import sbt.ScriptedPlugin.autoImport.scripted 2 | import sbt._ 3 | 4 | object Build extends AutoPlugin { 5 | 6 | override def requires: Plugins = ScriptedPlugin 7 | 8 | override def trigger = allRequirements 9 | 10 | object autoImport { 11 | 12 | lazy val scriptedAll = taskKey[Unit]("Runs all scripted tests") 13 | } 14 | 15 | import autoImport._ 16 | 17 | override def projectSettings: Seq[Def.Setting[_]] = Seq( 18 | scriptedAll := scripted.toTask("").value 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /project/Dependencies.scala: -------------------------------------------------------------------------------- 1 | import sbt.Keys._ 2 | import sbt._ 3 | 4 | object Versions { 5 | final val Scala212 = "2.12.20" 6 | final val Scala213 = "2.13.16" 7 | 8 | final val Scalajs = org.scalajs.sbtplugin.ScalaJSPlugin.autoImport.scalaJSVersion 9 | 10 | final val Caliban = "2.8.1" 11 | final val ScalaMeta = "4.9.8" 12 | } 13 | 14 | object Dependencies { 15 | val Caliban = "com.github.ghostdogpr" %% "caliban" % Versions.Caliban 16 | val ScalaMeta = "org.scalameta" %% "scalameta" % Versions.ScalaMeta 17 | def ScalaReflect = Def.setting { "org.scala-lang" % "scala-reflect" % scalaVersion.value } 18 | } 19 | -------------------------------------------------------------------------------- /project/PluginsAccessor.scala: -------------------------------------------------------------------------------- 1 | package sbt 2 | 3 | /** 4 | * Work around sbts private[sbt] on some plugin functions 5 | */ 6 | object PluginsAccessor { 7 | 8 | /** 9 | * Exclude a plugin 10 | */ 11 | def exclude(plugin: AutoPlugin): Plugins.Basic = Plugins.Exclude(plugin) 12 | } 13 | -------------------------------------------------------------------------------- /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.1") 2 | addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.3.1") 3 | addSbtPlugin("com.github.sbt" % "sbt-release" % "1.4.0") 4 | addSbtPlugin("org.jetbrains" % "sbt-idea-plugin" % "3.26.2") 5 | addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.19.0") 6 | addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.12.2") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/main/scala/com/goodcover/relay/Commands.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay 2 | 3 | import sbt.Logger 4 | import java.io.{File, InputStream} 5 | import scala.sys.process.Process 6 | import scala.sys.process.BasicIO 7 | import scala.sys.process.ProcessLogger 8 | 9 | object Commands { 10 | 11 | def run[A]( 12 | cmd: Seq[String], 13 | cwd: File, 14 | logger: Logger, 15 | outputProcess: InputStream => A 16 | ): Either[String, Option[A]] = { 17 | val toErrorLog = (is: InputStream) => { 18 | scala.io.Source.fromInputStream(is).getLines.foreach(msg => logger.error(msg)) 19 | is.close() 20 | } 21 | 22 | // Unfortunately a var is the only way to capture the result 23 | var result: Option[A] = None 24 | def outputCapture(o: InputStream): Unit = { 25 | result = Some(outputProcess(o)) 26 | o.close() 27 | () 28 | } 29 | 30 | logger.debug(s"Command: ${cmd.mkString(" ")}") 31 | val process = Process(cmd, cwd) 32 | val processIO = BasicIO.standard(false).withOutput(outputCapture).withError(toErrorLog) 33 | val code: Int = process.run(processIO).exitValue() 34 | if (code != 0) { 35 | Left(s"Non-zero exit code: $code") 36 | } else { 37 | Right(result) 38 | } 39 | } 40 | 41 | def run(cmd: Seq[String], cwd: File, logger: Logger): Unit = { 42 | val toInfoLog = (is: InputStream) => scala.io.Source.fromInputStream(is).getLines.foreach(msg => logger.info(msg)) 43 | run(cmd, cwd, logger, toInfoLog).fold(sys.error, _ => ()) 44 | } 45 | 46 | def start(cmd: Seq[String], cwd: File, logger: Logger): Process = 47 | Process(cmd, cwd).run(toProcessLogger(logger)) 48 | 49 | private def toProcessLogger(logger: Logger): ProcessLogger = 50 | ProcessLogger(msg => logger.info(msg), msg => logger.error(msg)) 51 | 52 | } 53 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/main/scala/com/goodcover/relay/ScalaRelayPlugin.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay 2 | 3 | import sbt.Keys._ 4 | import sbt._ 5 | 6 | object ScalaRelayPlugin extends AutoPlugin { 7 | 8 | override def requires: Plugins = ScalaRelayBasePlugin 9 | 10 | import ScalaRelayBasePlugin.autoImport._ 11 | 12 | override lazy val projectSettings: Seq[Setting[_]] = 13 | inConfig(Compile)(perConfigSettings) 14 | 15 | def perConfigSettings: Seq[Setting[_]] = 16 | Seq( 17 | sourceGenerators += relayConvert.taskValue.map(_.toSeq), 18 | resourceGenerators += relayCompile.taskValue.map(_.toSeq) 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/main/scala/com/goodcover/relay/codegen/DefinitionWriter.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay.codegen 2 | 3 | import java.io.Writer 4 | 5 | abstract class DefinitionWriter(writer: Writer) { 6 | 7 | protected val scalaWriter = new ScalaWriter(writer) 8 | 9 | def write(): Unit 10 | 11 | protected def definitionName: String 12 | 13 | protected def writePreamble(): Unit = { 14 | writePackageAndImports() 15 | writer.write("/*\n") 16 | writeDefinitionText() 17 | writer.write("*/\n\n") 18 | } 19 | 20 | private def writePackageAndImports(): Unit = { 21 | writer.write("package relay.generated\n\n") 22 | writeImports() 23 | } 24 | 25 | protected def writeImports(): Unit 26 | 27 | protected def writeDefinitionText(): Unit 28 | } 29 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/main/scala/com/goodcover/relay/codegen/Fields.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay.codegen 2 | 3 | object Fields { 4 | 5 | def isTypeName(name: String): Boolean = 6 | name == "__typename" 7 | 8 | def isID(name: String): Boolean = 9 | name == "__id" 10 | 11 | def isMetaField(name: String): Boolean = 12 | name.startsWith("__") 13 | } 14 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/main/scala/com/goodcover/relay/codegen/MutationWriter.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay.codegen 2 | 3 | import caliban.parsing.adt.Definition.ExecutableDefinition.OperationDefinition 4 | import caliban.parsing.adt.Definition.TypeSystemDefinition.TypeDefinition 5 | import caliban.parsing.adt.Document 6 | import com.goodcover.relay.GraphQLSchema 7 | 8 | import java.io.Writer 9 | 10 | class MutationWriter( 11 | writer: Writer, 12 | mutation: OperationDefinition, 13 | // TODO: GC-3158 - Remove documentText. 14 | documentText: String, 15 | document: Document, 16 | schema: GraphQLSchema, 17 | typeConverter: TypeConverter 18 | ) extends OperationWriter(writer, mutation, documentText, document, schema, typeConverter) { 19 | 20 | override def write(): Unit = { 21 | writePreamble() 22 | operationInputWriter.writeOperationInputType() 23 | writeOperationTrait() 24 | writeOperationObject() 25 | } 26 | 27 | override protected val operationObjectParent: String = "MutationTaggedNode" 28 | 29 | override protected def getOperationField(name: String): TypeDefinition.FieldDefinition = 30 | schema.mutationField(name) 31 | } 32 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/main/scala/com/goodcover/relay/codegen/QueryWriter.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay.codegen 2 | 3 | import caliban.parsing.adt.Definition.ExecutableDefinition.OperationDefinition 4 | import caliban.parsing.adt.Definition.TypeSystemDefinition.TypeDefinition 5 | import caliban.parsing.adt.Document 6 | import com.goodcover.relay.GraphQLSchema 7 | 8 | import java.io.Writer 9 | 10 | class QueryWriter( 11 | writer: Writer, 12 | query: OperationDefinition, 13 | // TODO: GC-3158 - Remove documentText. 14 | documentText: String, 15 | document: Document, 16 | schema: GraphQLSchema, 17 | typeConverter: TypeConverter 18 | ) extends OperationWriter(writer, query, documentText, document, schema, typeConverter) { 19 | 20 | override def write(): Unit = { 21 | writePreamble() 22 | operationInputWriter.writeOperationInputType() 23 | writeOperationTrait() 24 | writeOperationObject() 25 | } 26 | 27 | override protected val operationObjectParent: String = "QueryTaggedNode" 28 | 29 | override protected def getOperationField(name: String): TypeDefinition.FieldDefinition = 30 | schema.queryField(name) 31 | } 32 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/main/scala/com/goodcover/relay/codegen/Selections.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay.codegen 2 | 3 | import caliban.parsing.adt.Selection 4 | import com.goodcover.relay.codegen.Fields.isTypeName 5 | 6 | object Selections { 7 | 8 | def selectableFieldSelections(selections: List[Selection]): List[Selection.Field] = 9 | selections.collect { case field: Selection.Field if !isTypeName(field.name) => field } 10 | 11 | def inlineFragmentSelections(selections: List[Selection]): List[Selection.InlineFragment] = 12 | selections.collect { case inline: Selection.InlineFragment => inline } 13 | 14 | def hasTypeName(selections: List[Selection]): Boolean = 15 | selections.exists { 16 | case field: Selection.Field => isTypeName(field.name) 17 | case _ => false 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/main/scala/com/goodcover/relay/codegen/SubscriptionWriter.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay.codegen 2 | 3 | import caliban.parsing.adt.Definition.ExecutableDefinition.OperationDefinition 4 | import caliban.parsing.adt.Definition.TypeSystemDefinition.TypeDefinition 5 | import caliban.parsing.adt.Document 6 | import com.goodcover.relay.GraphQLSchema 7 | 8 | import java.io.Writer 9 | 10 | class SubscriptionWriter( 11 | writer: Writer, 12 | subscription: OperationDefinition, 13 | // TODO: GC-3158 - Remove documentText. 14 | documentText: String, 15 | document: Document, 16 | schema: GraphQLSchema, 17 | typeConverter: TypeConverter 18 | ) extends OperationWriter(writer, subscription, documentText, document, schema, typeConverter) { 19 | 20 | override def write(): Unit = { 21 | writePreamble() 22 | operationInputWriter.writeOperationInputType() 23 | writeOperationTrait() 24 | writeOperationObject() 25 | } 26 | 27 | override protected val operationObjectParent: String = "SubscriptionTaggedNode" 28 | 29 | override protected def getOperationField(name: String): TypeDefinition.FieldDefinition = 30 | schema.subscriptionField(name) 31 | } 32 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/main/scala/com/goodcover/relay/codegen/package.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay 2 | 3 | import caliban.parsing.adt.Definition.TypeSystemDefinition.TypeDefinition.{FieldDefinition, InputValueDefinition} 4 | import com.goodcover.relay.GraphQLSchema.FieldTypeDefinition 5 | 6 | package object codegen { 7 | 8 | private[codegen] type ArgLookup = String => Option[InputValueDefinition] 9 | private[codegen] type FieldLookup = String => Option[FieldDefinition] 10 | private[codegen] type FieldTypeLookup = String => Option[FieldTypeDefinition] 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basic/README.md: -------------------------------------------------------------------------------- 1 | # relay-compiler/basic 2 | 3 | Uses Relay to compile scala integrated files 4 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basic/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "testschema.graphql" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | logLevel := Level.Debug 26 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basic/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basic/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basic/src/main/resources/frags/Test.gql: -------------------------------------------------------------------------------- 1 | # graphql 2 | fragment Test_foo on Task { 3 | title 4 | } 5 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basic/src/main/scala/example/Main.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.Dynamic.literal 5 | import com.goodcover.relay.graphql 6 | import org.scalajs.dom 7 | 8 | import scala.scalajs.js.annotation.JSImport 9 | 10 | @graphql(""" 11 | query MainQuery { 12 | defaultSettings { 13 | notificationSounds 14 | } 15 | } 16 | """) 17 | @graphql(""" 18 | mutation MainMutation($input: ActorSubscribeInput!) { 19 | actorSubscribe(input: $input) { 20 | clientMutationId 21 | } 22 | } 23 | """) 24 | @graphql(""" 25 | fragment Main_foo on Task { 26 | title 27 | ...Test_foo 28 | } 29 | """) 30 | object frag 31 | 32 | case class Foo(i: Int)(val f: relay.generated.Main_foo) 33 | 34 | object Main extends App { 35 | 36 | def main(args: List[String]): Unit = { 37 | val q = relay.generated.MainQuery.query 38 | val q2 = relay.generated.Test_foo 39 | dom.console.log(q) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basic/test: -------------------------------------------------------------------------------- 1 | > Compile/relayCompile 2 | > Compile/npmUpdate 3 | > fastOptJS/webpack 4 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basicpersist/README.md: -------------------------------------------------------------------------------- 1 | # relay-compiler/basicpersist 2 | 3 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basicpersist/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basicpersist" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "testschema.graphql" 16 | 17 | relayDebug := true 18 | 19 | Compile / relayPersistedPath := Some((Compile / resourceDirectory).value / "persist.json") 20 | 21 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 22 | 23 | Compile / relayDisplayOnlyOnFailure := true 24 | 25 | webpack / version := "5.75.0" 26 | 27 | logLevel := Level.Debug 28 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basicpersist/expected/a.json: -------------------------------------------------------------------------------- 1 | { 2 | "02fa0ee609afe49b638bbf570eb6b5ca": "mutation MainMutation(\n $input: ActorSubscribeInput!\n) {\n actorSubscribe(input: $input) {\n clientMutationId\n }\n}\n", 3 | "db82ef36778a3c0f5a21478582b035dc": "query MainQuery {\n defaultSettings {\n notificationSounds\n }\n}\n" 4 | } -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basicpersist/expected/b.json: -------------------------------------------------------------------------------- 1 | { 2 | "02fa0ee609afe49b638bbf570eb6b5ca": "mutation MainMutation(\n $input: ActorSubscribeInput!\n) {\n actorSubscribe(input: $input) {\n clientMutationId\n }\n}\n", 3 | "db82ef36778a3c0f5a21478582b035dc": "query MainQuery {\n defaultSettings {\n notificationSounds\n }\n}\n", 4 | "54c3cf85b856a950d102f3c3757f94be": "query TestQuery {\n defaultSettings {\n notificationSounds\n cache_id\n }\n}\n" 5 | } 6 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basicpersist/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basicpersist/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basicpersist/src/main/resources/frags/Test.gql: -------------------------------------------------------------------------------- 1 | # graphql 2 | fragment Test_foo on Task { 3 | title 4 | } 5 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basicpersist/src/main/scala/example/Main.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.Dynamic.literal 5 | import com.goodcover.relay.graphql 6 | import org.scalajs.dom 7 | 8 | import scala.scalajs.js.annotation.JSImport 9 | 10 | @graphql(""" 11 | query MainQuery { 12 | defaultSettings { 13 | notificationSounds 14 | } 15 | } 16 | """) 17 | @graphql(""" 18 | mutation MainMutation($input: ActorSubscribeInput!) { 19 | actorSubscribe(input: $input) { 20 | clientMutationId 21 | } 22 | } 23 | """) 24 | @graphql(""" 25 | fragment Main_foo on Task { 26 | title 27 | } 28 | """) 29 | object frag 30 | 31 | case class Foo(i: Int)(val f: relay.generated.Main_foo) 32 | 33 | object Main extends App { 34 | 35 | def main(args: List[String]): Unit = { 36 | val q = relay.generated.MainQuery.query 37 | val q2 = relay.generated.Test_foo 38 | dom.console.log(q) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basicpersist/src/main/scala/example/Test.bak: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | @graphql(""" 4 | query TestQuery { 5 | defaultSettings { 6 | notificationSounds 7 | cache_id 8 | } 9 | } 10 | """) 11 | object TestQ { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/basicpersist/test: -------------------------------------------------------------------------------- 1 | > Compile/relayCompile 2 | > Compile/npmUpdate 3 | #$ pause 4 | $ exec echo "//" >> src/main/scala/example/Main.scala 5 | > Compile/relayCompile 6 | #$ pause 7 | $ copy-file src/main/scala/example/Test.bak src/main/scala/example/Test.scala 8 | > Compile/relayCompile 9 | #$ pause 10 | $ delete src/main/scala/example/Test.scala 11 | $ exec echo "//" >> src/main/scala/example/Main.scala 12 | > show Compile/relayExtract 13 | > show Compile/relayWrap 14 | > show Compile/relayCompile 15 | #$ pause 16 | # > fastOptJS/webpack 17 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/cache/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | Compile / relayExclude += "generated/**" 26 | 27 | logLevel := Level.Debug 28 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/cache/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/cache/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/cache/replace-version.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euxo pipefail 4 | 5 | if [[ "$OSTYPE" == "darwin"* ]]; then 6 | sed -E -i '' 's/"version":[0-9]+/"version":0/g' target/streams/compile/relayCompile/_global/streams/relay/compile/last 7 | else 8 | sed -E -i 's/"version":[0-9]+/"version":0/g' target/streams/compile/relayCompile/_global/streams/relay/compile/last 9 | fi 10 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/cache/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | query TestQuery { 2 | defaultSettings { 3 | notificationSounds 4 | cache_id 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/cache/src/main/resources/graphql/Test2.graphql: -------------------------------------------------------------------------------- 1 | query Test2Query { 2 | defaultSettings { 3 | notificationSounds 4 | cache_id 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/cache/src/main/resources/graphql/Test2.graphql.bak: -------------------------------------------------------------------------------- 1 | query Test2Query { 2 | defaultSettings { 3 | notificationSounds 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/connection/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | Compile / relayTypeScript := true 26 | 27 | logLevel := Level.Debug 28 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/connection/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/connection/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/connection/src/main/resources/graphql/Schema.graphqls: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | } 4 | 5 | type Query { 6 | viewer: Viewer 7 | } 8 | 9 | type Viewer { 10 | changes(before: String, after: String, first: Int, last: Int): ChangesConnection! 11 | } 12 | 13 | type ChangesConnection { 14 | pageInfo: PageInfo! 15 | edges: [ChangeEdge!]! 16 | } 17 | 18 | type ChangeEdge { 19 | cursor: String! 20 | node: Change! 21 | } 22 | 23 | type Change { 24 | description: String! 25 | } 26 | 27 | type PageInfo { 28 | hasNextPage: Boolean! 29 | hasPreviousPage: Boolean! 30 | startCursor: String 31 | endCursor: String 32 | } 33 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/connection/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | fragment Test_fragment on Viewer { 2 | changes(first: 10) @connection(key: "Test_fragment_changes") { 3 | __id 4 | edges { 5 | node { 6 | description 7 | } 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/connection/test: -------------------------------------------------------------------------------- 1 | > relayCompile 2 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/Test_fragment.graphql.ts expected/Test_fragment.graphql.ts 3 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/fragments/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | //outputPath in Compile := (resourceDirectory in Compile).value / "testschema.graphql" 14 | 15 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 16 | 17 | relaySchema := (Compile / resourceDirectory).value / "testschema.graphql" 18 | 19 | relayDebug := true 20 | 21 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 22 | 23 | Compile / relayDisplayOnlyOnFailure := true 24 | 25 | webpack / version := "5.75.0" 26 | 27 | logLevel := Level.Debug 28 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/fragments/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/fragments/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/fragments/src/main/resources/frags/Test.gql: -------------------------------------------------------------------------------- 1 | # graphql 2 | fragment Test_foo on Task { 3 | title 4 | } 5 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/fragments/test: -------------------------------------------------------------------------------- 1 | > Compile/relayCompile 2 | > Compile/npmUpdate 3 | > fastOptJS/webpack 4 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/multi-project/README.md: -------------------------------------------------------------------------------- 1 | # relay-compiler/multi-project 2 | 3 | Uses Relay to compile scala integrated files that span multiple projects. 4 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/multi-project/a/src/main/resources/graphql/StoryComponent.graphql: -------------------------------------------------------------------------------- 1 | fragment StoryComponent_story on Story { 2 | body { 3 | text 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/multi-project/a/src/main/scala/example/TaskComponent.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import com.goodcover.relay.macros.graphqlGen 4 | import relay.generated.TaskComponent_task 5 | 6 | object TaskComponent { 7 | 8 | private val fragment = graphqlGen(""" 9 | fragment TaskComponent_task on Task { 10 | title 11 | } 12 | """) 13 | 14 | def apply(ref: TaskComponent_task.Ref): Unit = { 15 | // useFragment(fragment, ref) 16 | // render... 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/multi-project/b/scalajs.webpack.config.js.template: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "entry": { 3 | "b-fastopt": [`${PWD}/target/scala-2.13/scalajs-bundler/main/b-fastopt.js`] 4 | }, 5 | "output": { 6 | "path": "${PWD}/target/scala-2.13/scalajs-bundler/main", 7 | "filename": "[name]-bundle.js" 8 | }, 9 | "mode": "development", 10 | "devServer": { 11 | "port": 8080 12 | }, 13 | "devtool": "source-map", 14 | "module": { 15 | "rules": [{ 16 | "test": new RegExp("\\.js$"), 17 | "enforce": "pre", 18 | "use": ["source-map-loader"] 19 | }] 20 | }, 21 | "resolve": { 22 | "modules": [ 23 | "node_modules", 24 | "${PWD}/target/scala-2.13/resource_managed/main", 25 | "${PWD}/../a/target/scala-2.13/resource_managed/main" 26 | ] 27 | } 28 | } -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/multi-project/b/src/main/scala/example/Main.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import com.goodcover.relay.macros.graphqlGen 4 | import relay.generated._ 5 | import org.scalajs.dom 6 | 7 | object Main extends App { 8 | 9 | private val query: MainQuery.type = graphqlGen(""" 10 | query MainQuery { 11 | task(number: 1) { 12 | ...TaskComponent_task 13 | } 14 | story { 15 | ...StoryComponent_story 16 | } 17 | } 18 | """) 19 | 20 | private val refetchable: Main_fragment.type = graphqlGen(""" 21 | fragment Main_fragment on Query @refetchable(queryName: "Main_fragment_Query") { 22 | task(number: $num) { 23 | ...TaskComponent_task 24 | } 25 | } 26 | """) 27 | 28 | // Make sure that everything can be linked properly. 29 | dom.console.log(MainQuery.sourceHash) 30 | dom.console.log(Main_fragment.sourceHash) 31 | dom.console.log(Main_fragment_Query.sourceHash) 32 | dom.console.log(TaskComponent_task.sourceHash) 33 | dom.console.log(StoryComponent_story.sourceHash) 34 | } 35 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/multi-project/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/multi-project/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/refetchable/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | Compile / relayTypeScript := true 26 | 27 | logLevel := Level.Debug 28 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/refetchable/expected/Test_fragment.graphql.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | // @ts-nocheck 4 | 5 | import { ReaderFragment } from "relay-runtime"; 6 | import { FragmentRefs as } from "relay-runtime"; 7 | export type Test_fragment = { 8 | readonly foo: { 9 | readonly bar: string | null; 10 | }; 11 | readonly " $refType": "Test_fragment"; 12 | }; 13 | export type Test_fragment$data = Test_fragment; 14 | export type Test_fragment$key = { 15 | readonly " $data"?: Test_fragment$data; 16 | readonly " $fragmentRefs": FragmentRefs<"Test_fragment">; 17 | }; 18 | 19 | 20 | 21 | const node: ReaderFragment = { 22 | "argumentDefinitions": [], 23 | "kind": "Fragment", 24 | "metadata": { 25 | "refetch": { 26 | "connection": null, 27 | "fragmentPathInResult": [], 28 | "operation": require('./NoArgs.graphql.ts') 29 | } 30 | }, 31 | "name": "Test_fragment", 32 | "selections": [ 33 | { 34 | "alias": null, 35 | "args": null, 36 | "concreteType": "Foo", 37 | "kind": "LinkedField", 38 | "name": "foo", 39 | "plural": false, 40 | "selections": [ 41 | { 42 | "alias": null, 43 | "args": null, 44 | "kind": "ScalarField", 45 | "name": "bar", 46 | "storageKey": null 47 | } 48 | ], 49 | "storageKey": null 50 | } 51 | ], 52 | "type": "Query", 53 | "abstractKey": null 54 | }; 55 | (node as any).hash = '00a5e5188f0fc4d7104e262577cadb9a'; 56 | export default node; 57 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/refetchable/expected/Test_fragment2.graphql.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | // @ts-nocheck 4 | 5 | import { ReaderFragment } from "relay-runtime"; 6 | import { FragmentRefs as } from "relay-runtime"; 7 | export type Test_fragment2 = { 8 | readonly oneArg: { 9 | readonly bar: string | null; 10 | }; 11 | readonly " $refType": "Test_fragment2"; 12 | }; 13 | export type Test_fragment2$data = Test_fragment2; 14 | export type Test_fragment2$key = { 15 | readonly " $data"?: Test_fragment2$data; 16 | readonly " $fragmentRefs": FragmentRefs<"Test_fragment2">; 17 | }; 18 | 19 | 20 | 21 | const node: ReaderFragment = { 22 | "argumentDefinitions": [ 23 | { 24 | "kind": "RootArgument", 25 | "name": "b" 26 | } 27 | ], 28 | "kind": "Fragment", 29 | "metadata": { 30 | "refetch": { 31 | "connection": null, 32 | "fragmentPathInResult": [], 33 | "operation": require('./Args.graphql.ts') 34 | } 35 | }, 36 | "name": "Test_fragment2", 37 | "selections": [ 38 | { 39 | "alias": null, 40 | "args": [ 41 | { 42 | "kind": "Variable", 43 | "name": "a", 44 | "variableName": "b" 45 | } 46 | ], 47 | "concreteType": "Foo", 48 | "kind": "LinkedField", 49 | "name": "oneArg", 50 | "plural": false, 51 | "selections": [ 52 | { 53 | "alias": null, 54 | "args": null, 55 | "kind": "ScalarField", 56 | "name": "bar", 57 | "storageKey": null 58 | } 59 | ], 60 | "storageKey": null 61 | } 62 | ], 63 | "type": "Query", 64 | "abstractKey": null 65 | }; 66 | (node as any).hash = 'f870ff586b9eccbe9bda3c7eaf535f2d'; 67 | export default node; 68 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/refetchable/expected/Test_fragment4.graphql.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | // @ts-nocheck 4 | 5 | import { ReaderFragment } from "relay-runtime"; 6 | import { FragmentRefs as } from "relay-runtime"; 7 | export type Test_fragment4 = { 8 | readonly objArg: { 9 | readonly bar: string | null; 10 | }; 11 | readonly " $refType": "Test_fragment4"; 12 | }; 13 | export type Test_fragment4$data = Test_fragment4; 14 | export type Test_fragment4$key = { 15 | readonly " $data"?: Test_fragment4$data; 16 | readonly " $fragmentRefs": FragmentRefs<"Test_fragment4">; 17 | }; 18 | 19 | 20 | 21 | const node: ReaderFragment = { 22 | "argumentDefinitions": [ 23 | { 24 | "kind": "RootArgument", 25 | "name": "thing" 26 | } 27 | ], 28 | "kind": "Fragment", 29 | "metadata": { 30 | "refetch": { 31 | "connection": null, 32 | "fragmentPathInResult": [], 33 | "operation": require('./ObjectArgs.graphql.ts') 34 | } 35 | }, 36 | "name": "Test_fragment4", 37 | "selections": [ 38 | { 39 | "alias": null, 40 | "args": [ 41 | { 42 | "kind": "Variable", 43 | "name": "thing", 44 | "variableName": "thing" 45 | } 46 | ], 47 | "concreteType": "Foo", 48 | "kind": "LinkedField", 49 | "name": "objArg", 50 | "plural": false, 51 | "selections": [ 52 | { 53 | "alias": null, 54 | "args": null, 55 | "kind": "ScalarField", 56 | "name": "bar", 57 | "storageKey": null 58 | } 59 | ], 60 | "storageKey": null 61 | } 62 | ], 63 | "type": "Query", 64 | "abstractKey": null 65 | }; 66 | (node as any).hash = '87e971b5a1eac4f3835cbac96f3635a8'; 67 | export default node; 68 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/refetchable/expected/Test_fragment5.graphql.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | // @ts-nocheck 4 | 5 | import { ReaderFragment } from "relay-runtime"; 6 | import { FragmentRefs as } from "relay-runtime"; 7 | export type Test_fragment5 = { 8 | readonly name: string; 9 | readonly id: string; 10 | readonly " $refType": "Test_fragment5"; 11 | }; 12 | export type Test_fragment5$data = Test_fragment5; 13 | export type Test_fragment5$key = { 14 | readonly " $data"?: Test_fragment5$data; 15 | readonly " $fragmentRefs": FragmentRefs<"Test_fragment5">; 16 | }; 17 | 18 | 19 | 20 | const node: ReaderFragment = { 21 | "argumentDefinitions": [], 22 | "kind": "Fragment", 23 | "metadata": { 24 | "refetch": { 25 | "connection": null, 26 | "fragmentPathInResult": [ 27 | "node" 28 | ], 29 | "operation": require('./ImplicitNodeArgs.graphql.ts'), 30 | "identifierField": "id" 31 | } 32 | }, 33 | "name": "Test_fragment5", 34 | "selections": [ 35 | { 36 | "alias": null, 37 | "args": null, 38 | "kind": "ScalarField", 39 | "name": "name", 40 | "storageKey": null 41 | }, 42 | { 43 | "alias": null, 44 | "args": null, 45 | "kind": "ScalarField", 46 | "name": "id", 47 | "storageKey": null 48 | } 49 | ], 50 | "type": "ImplicitNode", 51 | "abstractKey": "__isImplicitNode" 52 | }; 53 | (node as any).hash = 'bd12d7f8666e249e5b176f42a53f8f49'; 54 | export default node; 55 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/refetchable/expected/Test_viewer.graphql.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | // @ts-nocheck 4 | 5 | import { ReaderFragment } from "relay-runtime"; 6 | import { FragmentRefs as } from "relay-runtime"; 7 | export type Test_viewer = { 8 | readonly name: string; 9 | readonly " $refType": "Test_viewer"; 10 | }; 11 | export type Test_viewer$data = Test_viewer; 12 | export type Test_viewer$key = { 13 | readonly " $data"?: Test_viewer$data; 14 | readonly " $fragmentRefs": FragmentRefs<"Test_viewer">; 15 | }; 16 | 17 | 18 | 19 | const node: ReaderFragment = { 20 | "argumentDefinitions": [], 21 | "kind": "Fragment", 22 | "metadata": { 23 | "refetch": { 24 | "connection": null, 25 | "fragmentPathInResult": [ 26 | "viewer" 27 | ], 28 | "operation": require('./ViewerQuery.graphql.ts') 29 | } 30 | }, 31 | "name": "Test_viewer", 32 | "selections": [ 33 | { 34 | "alias": null, 35 | "args": null, 36 | "kind": "ScalarField", 37 | "name": "name", 38 | "storageKey": null 39 | } 40 | ], 41 | "type": "Viewer", 42 | "abstractKey": null 43 | }; 44 | (node as any).hash = '16bd6cce9f7608bf2fbc7e4080dc4e63'; 45 | export default node; 46 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/refetchable/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/refetchable/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/refetchable/src/main/resources/graphql/Schema.graphqls: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | } 4 | 5 | type Query { 6 | foo: Foo! 7 | oneArg(a: String): Foo! 8 | objArg(thing: Thing): Foo! 9 | node(nodeID: ID!): Node 10 | viewer: Viewer 11 | } 12 | 13 | interface Node { 14 | id: ID! 15 | } 16 | 17 | type Foo { 18 | bar: String 19 | args: Args 20 | } 21 | 22 | type Args { 23 | oneArg(a: String): Foo! 24 | objArg(thing: Thing): Foo! 25 | } 26 | 27 | input Thing { 28 | stuff: Stuff! 29 | } 30 | 31 | input Stuff { 32 | junk: String 33 | } 34 | 35 | interface ImplicitNode { 36 | id: ID! 37 | name: String! 38 | } 39 | 40 | type Viewer { 41 | name: String! 42 | } 43 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/refetchable/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | fragment Test_fragment on Query @refetchable(queryName: "NoArgs") { 2 | foo { 3 | bar 4 | } 5 | } 6 | 7 | fragment Test_fragment2 on Query @refetchable(queryName: "Args") { 8 | oneArg(a: $b) { 9 | bar 10 | } 11 | } 12 | 13 | fragment Test_fragment3 on Query @refetchable(queryName: "NestedArgs") { 14 | foo { 15 | args { 16 | oneArg(a: $b) { 17 | bar 18 | } 19 | } 20 | } 21 | } 22 | 23 | fragment Test_fragment4 on Query @refetchable(queryName: "ObjectArgs") { 24 | objArg(thing: $thing) { 25 | bar 26 | } 27 | } 28 | 29 | fragment Test_fragment5 on ImplicitNode @refetchable(queryName: "ImplicitNodeArgs") { 30 | name 31 | } 32 | 33 | fragment Test_args on Args { 34 | oneArg(a: $b) { 35 | bar 36 | } 37 | } 38 | 39 | fragment Test_fragment6 on Query @refetchable(queryName: "ArgsOfSpread") { 40 | foo { 41 | args { 42 | ...Test_args 43 | } 44 | } 45 | } 46 | 47 | fragment Test_viewer on Viewer @refetchable(queryName: "ViewerQuery") { 48 | name 49 | } 50 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/refetchable/test: -------------------------------------------------------------------------------- 1 | > relayCompile 2 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/Args.graphql.ts expected/Args.graphql.ts 3 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/NestedArgs.graphql.ts expected/NestedArgs.graphql.ts 4 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/NoArgs.graphql.ts expected/NoArgs.graphql.ts 5 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/ObjectArgs.graphql.ts expected/ObjectArgs.graphql.ts 6 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/ImplicitNodeArgs.graphql.ts expected/ImplicitNodeArgs.graphql.ts 7 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/ArgsOfSpread.graphql.ts expected/ArgsOfSpread.graphql.ts 8 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/ViewerQuery.graphql.ts expected/ViewerQuery.graphql.ts 9 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/Test_fragment.graphql.ts expected/Test_fragment.graphql.ts 10 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/Test_fragment2.graphql.ts expected/Test_fragment2.graphql.ts 11 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/Test_fragment3.graphql.ts expected/Test_fragment3.graphql.ts 12 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/Test_fragment4.graphql.ts expected/Test_fragment4.graphql.ts 13 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/Test_fragment5.graphql.ts expected/Test_fragment5.graphql.ts 14 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/Test_fragment6.graphql.ts expected/Test_fragment6.graphql.ts 15 | $ must-mirror target/scala-2.13/resource_managed/main/__generated__/Test_viewer.graphql.ts expected/Test_viewer.graphql.ts 16 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/typescript/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | Compile / relayTypeScript := true 26 | 27 | logLevel := Level.Debug 28 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/typescript/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/typescript/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/typescript/src/main/resources/graphql/Schema.graphqls: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | mutation: Mutation 4 | subscription: Subscription 5 | } 6 | 7 | type Query { 8 | noVariables: Node! 9 | objectVariable(input: Input): Node! 10 | nestedObjectVariable(nested: Nested): Node! 11 | primitiveVariable(a: String): Node! 12 | listVariable(as: [String]): Node! 13 | multipleVariables(a: String, b: String): Node! 14 | primitiveResponse(a: String): String! 15 | optionalPrimitiveResponse(a: String): String 16 | listResponse(a: String): [String!]! 17 | } 18 | 19 | input Input { 20 | a: String! 21 | } 22 | 23 | input Nested { 24 | input: Input! 25 | } 26 | 27 | type Node { 28 | id: ID! 29 | } 30 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-compiler/typescript/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | query TestNoVariablesQuery { 2 | noVariables { 3 | id 4 | } 5 | } 6 | 7 | query TestObjectVariableQuery($input: Input!) { 8 | objectVariable(input: $input) { 9 | id 10 | } 11 | } 12 | 13 | query TestOptionalObjectVariableQuery($input: Input) { 14 | objectVariable(input: $input) { 15 | id 16 | } 17 | } 18 | 19 | query TestNestedObjectVariableQuery($nested: Nested) { 20 | nestedObjectVariable(nested: $nested) { 21 | id 22 | } 23 | } 24 | 25 | query TestPrimitiveVariableQuery($a: String!) { 26 | primitiveVariable(a: $a) { 27 | id 28 | } 29 | } 30 | 31 | query TestOptionalPrimitiveVariableQuery($a: String) { 32 | primitiveVariable(a: $a) { 33 | id 34 | } 35 | } 36 | 37 | query TestListVariableQuery($as: [String!]!) { 38 | listVariable(as: $as) { 39 | id 40 | } 41 | } 42 | 43 | query TestOptionalListVariableQuery($as: [String!]) { 44 | listVariable(as: $as) { 45 | id 46 | } 47 | } 48 | 49 | query TestMultipleVariablesQuery($a: String!, $b: String!) { 50 | multipleVariables(a: $a, b: $b) { 51 | id 52 | } 53 | } 54 | 55 | query TestPrimitiveResponseQuery($a: String!) { 56 | primitiveResponse(a: $a) 57 | } 58 | 59 | query TestOptionalPrimitiveResponseQuery($a: String!) { 60 | optionalPrimitiveResponse(a: $a) 61 | } 62 | 63 | query TestListResponseQuery($a: String!) { 64 | listResponse(a: $a) 65 | } 66 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/alias/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | // Avoid picking up the expected files in the unmanagedSources. 26 | unmanagedSources / excludeFilter ~= (_ || "*.scala") 27 | 28 | logLevel := Level.Debug 29 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/alias/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/alias/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/alias/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | fragment Test_node on Node { 2 | no: __typename 3 | moniker: name 4 | content: body { 5 | words: text 6 | ...Test_text 7 | } 8 | ... on User { 9 | surname: lastName 10 | msg: message { 11 | txt: text 12 | } 13 | } 14 | } 15 | 16 | fragment Test_text on Text { 17 | gab: text 18 | } 19 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/alias/test: -------------------------------------------------------------------------------- 1 | # This should convert as expected. 2 | > relayConvert 3 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/Test_node.scala Test_node.expected.scala 4 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/basic/TestSubscription.expected.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | subscription TestSubscription($input: FeedbackLikeInput!) { 9 | feedbackLikeSubscribe(input: $input) { 10 | clientSubscriptionId 11 | } 12 | } 13 | */ 14 | 15 | trait TestSubscriptionInput extends js.Object { 16 | val input: FeedbackLikeInput 17 | } 18 | 19 | object TestSubscriptionInput { 20 | def apply( 21 | input: FeedbackLikeInput 22 | ): TestSubscriptionInput = 23 | js.Dynamic.literal( 24 | input = input 25 | ).asInstanceOf[TestSubscriptionInput] 26 | } 27 | 28 | @js.native 29 | trait TestSubscription extends js.Object { 30 | val feedbackLikeSubscribe: TestSubscription.FeedbackLikeSubscribe | Null 31 | } 32 | 33 | object TestSubscription extends _root_.com.goodcover.relay.SubscriptionTaggedNode[TestSubscriptionInput, TestSubscription] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait FeedbackLikeSubscribe extends js.Object { 38 | val clientSubscriptionId: String | Null 39 | } 40 | 41 | def newInput( 42 | input: _root_.relay.generated.FeedbackLikeInput 43 | ): _root_.relay.generated.TestSubscriptionInput = 44 | _root_.relay.generated.TestSubscriptionInput( 45 | input 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestSubscription.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/basic/Test_fragment.expected.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_fragment on Viewer { 9 | actor { 10 | id 11 | address { 12 | city 13 | country 14 | } 15 | } 16 | } 17 | */ 18 | 19 | @js.native 20 | trait Test_fragment extends js.Object { 21 | val actor: Test_fragment.Actor | Null 22 | } 23 | 24 | object Test_fragment extends _root_.com.goodcover.relay.FragmentTaggedNode[Test_fragment] { 25 | type Ctor[T] = T 26 | 27 | @js.native 28 | trait ActorAddress extends js.Object { 29 | val city: String | Null 30 | val country: String | Null 31 | } 32 | 33 | @js.native 34 | trait Actor extends js.Object { 35 | val id: String 36 | val address: ActorAddress | Null 37 | } 38 | 39 | type Query = _root_.com.goodcover.relay.ReaderFragment[Ctor, Out] 40 | 41 | @js.native 42 | @JSImport("__generated__/Test_fragment.graphql", JSImport.Default) 43 | private object node extends js.Object 44 | 45 | lazy val query: Query = node.asInstanceOf[Query] 46 | 47 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 48 | } 49 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/basic/Test_fragmentInterface.expected.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_fragmentInterface on Node { 9 | name 10 | } 11 | */ 12 | 13 | @js.native 14 | trait Test_fragmentInterface extends js.Object { 15 | val name: String | Null 16 | } 17 | 18 | object Test_fragmentInterface extends _root_.com.goodcover.relay.FragmentTaggedNode[Test_fragmentInterface] { 19 | type Ctor[T] = T 20 | 21 | type Query = _root_.com.goodcover.relay.ReaderFragment[Ctor, Out] 22 | 23 | @js.native 24 | @JSImport("__generated__/Test_fragmentInterface.graphql", JSImport.Default) 25 | private object node extends js.Object 26 | 27 | lazy val query: Query = node.asInstanceOf[Query] 28 | 29 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 30 | } 31 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/basic/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | // Avoid picking up the expected files in the unmanagedSources. 26 | unmanagedSources / excludeFilter ~= (_ || "*.scala") 27 | 28 | logLevel := Level.Debug 29 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/basic/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/basic/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/basic/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | # Extracted from src/main/scala/example/Test.scala 2 | # This is rad! 3 | query TestQuery { 4 | viewer { 5 | actor { 6 | id 7 | address { 8 | city 9 | country 10 | } 11 | } 12 | allTimezones { 13 | timezone 14 | } 15 | } 16 | } 17 | 18 | mutation TestMutation($input: ActorSubscribeInput!) { 19 | actorSubscribe(input: $input) { 20 | clientMutationId 21 | subscribee { 22 | id 23 | address { 24 | city 25 | country 26 | } 27 | } 28 | } 29 | } 30 | 31 | subscription TestSubscription($input: FeedbackLikeInput!) { 32 | feedbackLikeSubscribe(input: $input) { 33 | clientSubscriptionId 34 | } 35 | } 36 | 37 | fragment Test_fragment on Viewer { 38 | actor { 39 | id 40 | address { 41 | city 42 | country 43 | } 44 | } 45 | } 46 | 47 | fragment Test_fragmentInterface on Node { 48 | name 49 | } 50 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/basic/test: -------------------------------------------------------------------------------- 1 | # This should convert as expected. 2 | > relayConvert 3 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/TestQuery.scala TestQuery.expected.scala 4 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/TestMutation.scala TestMutation.expected.scala 5 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/TestSubscription.scala TestSubscription.expected.scala 6 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/Test_fragment.scala Test_fragment.expected.scala 7 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/Test_fragmentInterface.scala Test_fragmentInterface.expected.scala 8 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/cache/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | logLevel := Level.Debug 26 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/cache/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/cache/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/cache/replace-version.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euxo pipefail 4 | 5 | if [[ "$OSTYPE" == "darwin"* ]]; then 6 | sed -E -i '' 's/"version":[0-9]+/"version":0/g' target/streams/compile/relayConvert/_global/streams/relay/convert/last 7 | else 8 | sed -E -i 's/"version":[0-9]+/"version":0/g' target/streams/compile/relayConvert/_global/streams/relay/convert/last 9 | fi 10 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/cache/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | query TestQuery { 2 | defaultSettings { 3 | notificationSounds 4 | cache_id 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/cache/src/main/resources/graphql/Test2.graphql: -------------------------------------------------------------------------------- 1 | query TestQuery2 { 2 | defaultSettings { 3 | notificationSounds 4 | cache_id 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/cache/src/main/resources/graphql/Test2.graphql.bak: -------------------------------------------------------------------------------- 1 | query TestQuery2 { 2 | defaultSettings { 3 | notificationSounds 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/collision/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | logLevel := Level.Debug 26 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/collision/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/collision/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/collision/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | query TestQuery { 2 | defaultSettings { 3 | notificationSounds 4 | cache_id 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/collision/src/main/resources/graphql/Test2.graphql: -------------------------------------------------------------------------------- 1 | query TestQuery { 2 | defaultSettings { 3 | notificationSounds 4 | cache_id 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/collision/test: -------------------------------------------------------------------------------- 1 | # Two operations with the same name is not allowed. 2 | -> relayConvert 3 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/connection/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | // Avoid picking up the expected files in the unmanagedSources. 26 | unmanagedSources / excludeFilter ~= (_ || "*.scala") 27 | 28 | logLevel := Level.Debug 29 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/connection/expected/Test_fragment.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_fragment on Viewer { 9 | changes(first: 10) @connection(key: "Test_fragment_changes") { 10 | __id 11 | edges { 12 | node { 13 | description 14 | } 15 | } 16 | } 17 | } 18 | */ 19 | 20 | @js.native 21 | trait Test_fragment extends js.Object { 22 | val changes: Test_fragment.Changes 23 | } 24 | 25 | object Test_fragment extends _root_.com.goodcover.relay.FragmentTaggedNode[Test_fragment] { 26 | type Ctor[T] = T 27 | 28 | @js.native 29 | trait ChangesEdgesNode extends js.Object { 30 | val description: String 31 | } 32 | 33 | @js.native 34 | trait ChangesEdges extends js.Object { 35 | val node: ChangesEdgesNode 36 | } 37 | 38 | @js.native 39 | trait Changes extends js.Object { 40 | val __id: String 41 | val edges: js.Array[ChangesEdges] 42 | } 43 | 44 | type Query = _root_.com.goodcover.relay.ReaderFragment[Ctor, Out] 45 | 46 | @js.native 47 | @JSImport("__generated__/Test_fragment.graphql", JSImport.Default) 48 | private object node extends js.Object 49 | 50 | lazy val query: Query = node.asInstanceOf[Query] 51 | 52 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 53 | } 54 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/connection/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/connection/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/connection/src/main/resources/graphql/Schema.graphqls: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | } 4 | 5 | type Query { 6 | viewer: Viewer 7 | } 8 | 9 | type Viewer { 10 | changes(before: String, after: String, first: Int, last: Int): ChangesConnection! 11 | } 12 | 13 | type ChangesConnection { 14 | pageInfo: PageInfo! 15 | edges: [ChangeEdge!]! 16 | } 17 | 18 | type ChangeEdge { 19 | cursor: String! 20 | node: Change! 21 | } 22 | 23 | type Change { 24 | description: String! 25 | } 26 | 27 | type PageInfo { 28 | hasNextPage: Boolean! 29 | hasPreviousPage: Boolean! 30 | startCursor: String 31 | endCursor: String 32 | } 33 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/connection/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | fragment Test_fragment on Viewer { 2 | changes(first: 10) @connection(key: "Test_fragment_changes") { 3 | __id 4 | edges { 5 | node { 6 | description 7 | } 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/connection/test: -------------------------------------------------------------------------------- 1 | # This should convert as expected. 2 | > relayConvert 3 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/Test_fragment.scala expected/Test_fragment.scala 4 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/error-recovery/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | logLevel := Level.Debug 26 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/error-recovery/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/error-recovery/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/error-recovery/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | query TestQuery { 2 | defaultSettings { 3 | notificationSounds { 4 | enabled 5 | } 6 | cache_id 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/error-recovery/src/main/resources/graphql/Test.graphql.bak: -------------------------------------------------------------------------------- 1 | query TestQuery { 2 | defaultSettings { 3 | notificationSounds 4 | cache_id 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/error-recovery/test: -------------------------------------------------------------------------------- 1 | # Make sure that we can recover from errors. 2 | # If done incorrectly, the partial file from the previous failed run can cause the collision 3 | # detection to report a false positive. 4 | -> relayConvert 5 | $ copy-file src/main/resources/graphql/Test.graphql.bak src/main/resources/graphql/Test.graphql 6 | > relayConvert 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/fragment-spread/Test_viewer.expected.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_viewer on Viewer { 9 | ...Test_viewer2 10 | actor { 11 | address { 12 | ...Test_address 13 | } 14 | } 15 | } 16 | */ 17 | 18 | @js.native 19 | trait Test_viewer extends js.Object { 20 | val actor: Test_viewer.Actor | Null 21 | } 22 | 23 | object Test_viewer extends _root_.com.goodcover.relay.FragmentTaggedNode[Test_viewer] { 24 | type Ctor[T] = T 25 | 26 | @js.native 27 | trait ActorAddress extends js.Object 28 | 29 | @js.native 30 | trait Actor extends js.Object { 31 | val address: ActorAddress | Null 32 | } 33 | 34 | implicit class Test_viewer2Test_viewer2Ref(f: Test_viewer) extends _root_.com.goodcover.relay.CastToFragmentRef[Test_viewer, Test_viewer2](f) { 35 | def toTest_viewer2: _root_.com.goodcover.relay.FragmentRef[Test_viewer2] = castToRef 36 | } 37 | 38 | implicit class ActorAddress2Test_addressRef(f: ActorAddress) extends _root_.com.goodcover.relay.CastToFragmentRef[ActorAddress, Test_address](f) { 39 | def toTest_address: _root_.com.goodcover.relay.FragmentRef[Test_address] = castToRef 40 | } 41 | 42 | type Query = _root_.com.goodcover.relay.ReaderFragment[Ctor, Out] 43 | 44 | @js.native 45 | @JSImport("__generated__/Test_viewer.graphql", JSImport.Default) 46 | private object node extends js.Object 47 | 48 | lazy val query: Query = node.asInstanceOf[Query] 49 | 50 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 51 | } 52 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/fragment-spread/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | // Avoid picking up the expected files in the unmanagedSources. 26 | unmanagedSources / excludeFilter ~= (_ || "*.scala") 27 | 28 | logLevel := Level.Debug 29 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/fragment-spread/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/fragment-spread/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/fragment-spread/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | query TestQuery { 2 | viewer { 3 | ...Test_viewer 4 | actor { 5 | address { 6 | ...Test_address 7 | } 8 | } 9 | } 10 | } 11 | 12 | mutation TestMutation($input: ActorSubscribeInput!) { 13 | actorSubscribe(input: $input) { 14 | clientMutationId 15 | ...Test_payload 16 | subscribee { 17 | address { 18 | ...Test_address 19 | } 20 | } 21 | } 22 | } 23 | 24 | subscription TestSubscription($input: FeedbackLikeInput!) { 25 | feedbackLikeSubscribe(input: $input) { 26 | clientSubscriptionId 27 | ...Test_payload2 28 | feedback { 29 | ...Test_feedback 30 | } 31 | } 32 | } 33 | 34 | fragment Test_payload on ActorSubscribeResponsePayload { 35 | subscribee { 36 | address { 37 | ...Test_address 38 | } 39 | } 40 | } 41 | 42 | fragment Test_payload2 on FeedbackLikeResponsePayload { 43 | feedback { 44 | ...Test_feedback 45 | } 46 | } 47 | 48 | fragment Test_viewer on Viewer { 49 | ...Test_viewer2 50 | actor { 51 | address { 52 | ...Test_address 53 | } 54 | } 55 | } 56 | 57 | fragment Test_viewer2 on Viewer { 58 | actor { 59 | address { 60 | ...Test_address 61 | } 62 | } 63 | } 64 | 65 | fragment Test_address on StreetAddress { 66 | city 67 | country 68 | } 69 | 70 | fragment Test_feedback on Feedback { 71 | lastName 72 | } 73 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/fragment-spread/test: -------------------------------------------------------------------------------- 1 | # This should convert as expected. 2 | > relayConvert 3 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/TestQuery.scala TestQuery.expected.scala 4 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/TestMutation.scala TestMutation.expected.scala 5 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/TestSubscription.scala TestSubscription.expected.scala 6 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/Test_viewer.scala Test_viewer.expected.scala 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/inline-directive/Test_fragment.expected.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_fragment on Node @inline { 9 | name 10 | } 11 | */ 12 | 13 | @js.native 14 | trait Test_fragment extends js.Object { 15 | val name: String 16 | } 17 | 18 | object Test_fragment extends _root_.com.goodcover.relay.FragmentTaggedNode[Test_fragment] { 19 | type Ctor[T] = T 20 | 21 | type Query = _root_.com.goodcover.relay.ReaderInlineDataFragment[Ctor, Out] 22 | 23 | @js.native 24 | @JSImport("__generated__/Test_fragment.graphql", JSImport.Default) 25 | private object node extends js.Object 26 | 27 | lazy val query: Query = node.asInstanceOf[Query] 28 | 29 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 30 | } 31 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/inline-directive/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | // Avoid picking up the expected files in the unmanagedSources. 26 | unmanagedSources / excludeFilter ~= (_ || "*.scala") 27 | 28 | Compile / relayConvertTypeMappings += "Foo" -> "Bar" 29 | 30 | logLevel := Level.Debug 31 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/inline-directive/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/inline-directive/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/inline-directive/src/main/resources/graphql/Schema.graphqls: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | } 4 | 5 | type Query { 6 | 7 | } 8 | 9 | type Node { 10 | name: String! 11 | } 12 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/inline-directive/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | fragment Test_fragment on Node @inline { 2 | name 3 | } 4 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/inline-directive/test: -------------------------------------------------------------------------------- 1 | > relayConvert 2 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/Test_fragment.scala Test_fragment.expected.scala 3 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/inline-fragment/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | // Avoid picking up the expected files in the unmanagedSources. 26 | unmanagedSources / excludeFilter ~= (_ || "*.scala") 27 | 28 | logLevel := Level.Debug 29 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/inline-fragment/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/inline-fragment/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/inline-fragment/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | fragment Test_node on Node { 2 | __typename 3 | ... on User { 4 | name 5 | } 6 | ... on Page { 7 | name 8 | actor { 9 | __typename 10 | id 11 | ... on User { 12 | name 13 | ...Test_user 14 | } 15 | } 16 | } 17 | } 18 | 19 | fragment Test_user on User { 20 | message 21 | } 22 | 23 | query TestQuery { 24 | maybeNode { 25 | __typename 26 | ... on Story { 27 | author { 28 | lastName 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/inline-fragment/test: -------------------------------------------------------------------------------- 1 | # This should convert as expected. 2 | > relayConvert 3 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/Test_node.scala Test_node.expected.scala 4 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/TestQuery.scala TestQuery.expected.scala 5 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | // Avoid picking up the expected files in the unmanagedSources. 26 | unmanagedSources / excludeFilter ~= (_ || "*.scala") 27 | 28 | logLevel := Level.Debug 29 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/expected/Input.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | 6 | /* 7 | input Input { 8 | a: String! 9 | } 10 | */ 11 | 12 | trait Input extends js.Object { 13 | val a: String 14 | } 15 | 16 | object Input { 17 | def apply( 18 | a: String 19 | ): Input = 20 | js.Dynamic.literal( 21 | a = a 22 | ).asInstanceOf[Input] 23 | } 24 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/expected/Nested.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | 6 | /* 7 | input Nested { 8 | input: Input! 9 | } 10 | */ 11 | 12 | trait Nested extends js.Object { 13 | val input: Input 14 | } 15 | 16 | object Nested { 17 | def apply( 18 | input: Input 19 | ): Nested = 20 | js.Dynamic.literal( 21 | input = input 22 | ).asInstanceOf[Nested] 23 | } 24 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/expected/TestListResponseMutation.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | mutation TestListResponseMutation($a: String!) { 9 | listResponse(a: $a) 10 | } 11 | */ 12 | 13 | trait TestListResponseMutationInput extends js.Object { 14 | val a: String 15 | } 16 | 17 | object TestListResponseMutationInput { 18 | def apply( 19 | a: String 20 | ): TestListResponseMutationInput = 21 | js.Dynamic.literal( 22 | a = a 23 | ).asInstanceOf[TestListResponseMutationInput] 24 | } 25 | 26 | @js.native 27 | trait TestListResponseMutation extends js.Object { 28 | val listResponse: js.Array[String] 29 | } 30 | 31 | object TestListResponseMutation extends _root_.com.goodcover.relay.MutationTaggedNode[TestListResponseMutationInput, TestListResponseMutation] { 32 | type Ctor[T] = T 33 | 34 | def newInput( 35 | a: String 36 | ): _root_.relay.generated.TestListResponseMutationInput = 37 | _root_.relay.generated.TestListResponseMutationInput( 38 | a 39 | ) 40 | 41 | type Query = _root_.com.goodcover.relay.ConcreteRequest 42 | 43 | @js.native 44 | @JSImport("__generated__/TestListResponseMutation.graphql", JSImport.Default) 45 | private object node extends js.Object 46 | 47 | lazy val query: Query = node.asInstanceOf[Query] 48 | 49 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 50 | } 51 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/expected/TestListVariableMutation.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | mutation TestListVariableMutation($as: [String!]!) { 9 | listVariable(as: $as) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestListVariableMutationInput extends js.Object { 16 | val as: js.Array[String] 17 | } 18 | 19 | object TestListVariableMutationInput { 20 | def apply( 21 | as: js.Array[String] 22 | ): TestListVariableMutationInput = 23 | js.Dynamic.literal( 24 | as = as 25 | ).asInstanceOf[TestListVariableMutationInput] 26 | } 27 | 28 | @js.native 29 | trait TestListVariableMutation extends js.Object { 30 | val listVariable: TestListVariableMutation.ListVariable 31 | } 32 | 33 | object TestListVariableMutation extends _root_.com.goodcover.relay.MutationTaggedNode[TestListVariableMutationInput, TestListVariableMutation] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait ListVariable extends js.Object { 38 | val id: String 39 | } 40 | 41 | def newInput( 42 | as: js.Array[String] 43 | ): _root_.relay.generated.TestListVariableMutationInput = 44 | _root_.relay.generated.TestListVariableMutationInput( 45 | as 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestListVariableMutation.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/expected/TestNoVariablesMutation.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | mutation TestNoVariablesMutation { 9 | noVariables { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestNoVariablesMutationInput extends js.Object 16 | 17 | object TestNoVariablesMutationInput { 18 | def apply(): TestNoVariablesMutationInput = js.Dynamic.literal().asInstanceOf[TestNoVariablesMutationInput] 19 | } 20 | 21 | @js.native 22 | trait TestNoVariablesMutation extends js.Object { 23 | val noVariables: TestNoVariablesMutation.NoVariables 24 | } 25 | 26 | object TestNoVariablesMutation extends _root_.com.goodcover.relay.MutationTaggedNode[TestNoVariablesMutationInput, TestNoVariablesMutation] { 27 | type Ctor[T] = T 28 | 29 | @js.native 30 | trait NoVariables extends js.Object { 31 | val id: String 32 | } 33 | 34 | def newInput(): _root_.relay.generated.TestNoVariablesMutationInput = _root_.relay.generated.TestNoVariablesMutationInput() 35 | 36 | type Query = _root_.com.goodcover.relay.ConcreteRequest 37 | 38 | @js.native 39 | @JSImport("__generated__/TestNoVariablesMutation.graphql", JSImport.Default) 40 | private object node extends js.Object 41 | 42 | lazy val query: Query = node.asInstanceOf[Query] 43 | 44 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 45 | } 46 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/expected/TestObjectVariableMutation.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | mutation TestObjectVariableMutation($input: Input!) { 9 | objectVariable(input: $input) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestObjectVariableMutationInput extends js.Object { 16 | val input: Input 17 | } 18 | 19 | object TestObjectVariableMutationInput { 20 | def apply( 21 | input: Input 22 | ): TestObjectVariableMutationInput = 23 | js.Dynamic.literal( 24 | input = input 25 | ).asInstanceOf[TestObjectVariableMutationInput] 26 | } 27 | 28 | @js.native 29 | trait TestObjectVariableMutation extends js.Object { 30 | val objectVariable: TestObjectVariableMutation.ObjectVariable 31 | } 32 | 33 | object TestObjectVariableMutation extends _root_.com.goodcover.relay.MutationTaggedNode[TestObjectVariableMutationInput, TestObjectVariableMutation] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait ObjectVariable extends js.Object { 38 | val id: String 39 | } 40 | 41 | def newInput( 42 | input: _root_.relay.generated.Input 43 | ): _root_.relay.generated.TestObjectVariableMutationInput = 44 | _root_.relay.generated.TestObjectVariableMutationInput( 45 | input 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestObjectVariableMutation.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/expected/TestOptionalListVariableMutation.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | mutation TestOptionalListVariableMutation($as: [String!]) { 9 | listVariable(as: $as) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestOptionalListVariableMutationInput extends js.Object { 16 | val as: js.Array[String] | Null 17 | } 18 | 19 | object TestOptionalListVariableMutationInput { 20 | def apply( 21 | as: js.Array[String] | Null = null 22 | ): TestOptionalListVariableMutationInput = 23 | js.Dynamic.literal( 24 | as = as 25 | ).asInstanceOf[TestOptionalListVariableMutationInput] 26 | } 27 | 28 | @js.native 29 | trait TestOptionalListVariableMutation extends js.Object { 30 | val listVariable: TestOptionalListVariableMutation.ListVariable 31 | } 32 | 33 | object TestOptionalListVariableMutation extends _root_.com.goodcover.relay.MutationTaggedNode[TestOptionalListVariableMutationInput, TestOptionalListVariableMutation] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait ListVariable extends js.Object { 38 | val id: String 39 | } 40 | 41 | def newInput( 42 | as: js.Array[String] | Null = null 43 | ): _root_.relay.generated.TestOptionalListVariableMutationInput = 44 | _root_.relay.generated.TestOptionalListVariableMutationInput( 45 | as 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestOptionalListVariableMutation.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/expected/TestOptionalPrimitiveResponseMutation.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | mutation TestOptionalPrimitiveResponseMutation($a: String!) { 9 | optionalPrimitiveResponse(a: $a) 10 | } 11 | */ 12 | 13 | trait TestOptionalPrimitiveResponseMutationInput extends js.Object { 14 | val a: String 15 | } 16 | 17 | object TestOptionalPrimitiveResponseMutationInput { 18 | def apply( 19 | a: String 20 | ): TestOptionalPrimitiveResponseMutationInput = 21 | js.Dynamic.literal( 22 | a = a 23 | ).asInstanceOf[TestOptionalPrimitiveResponseMutationInput] 24 | } 25 | 26 | @js.native 27 | trait TestOptionalPrimitiveResponseMutation extends js.Object { 28 | val optionalPrimitiveResponse: String | Null 29 | } 30 | 31 | object TestOptionalPrimitiveResponseMutation extends _root_.com.goodcover.relay.MutationTaggedNode[TestOptionalPrimitiveResponseMutationInput, TestOptionalPrimitiveResponseMutation] { 32 | type Ctor[T] = T 33 | 34 | def newInput( 35 | a: String 36 | ): _root_.relay.generated.TestOptionalPrimitiveResponseMutationInput = 37 | _root_.relay.generated.TestOptionalPrimitiveResponseMutationInput( 38 | a 39 | ) 40 | 41 | type Query = _root_.com.goodcover.relay.ConcreteRequest 42 | 43 | @js.native 44 | @JSImport("__generated__/TestOptionalPrimitiveResponseMutation.graphql", JSImport.Default) 45 | private object node extends js.Object 46 | 47 | lazy val query: Query = node.asInstanceOf[Query] 48 | 49 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 50 | } 51 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/expected/TestPrimitiveResponseMutation.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | mutation TestPrimitiveResponseMutation($a: String!) { 9 | primitiveResponse(a: $a) 10 | } 11 | */ 12 | 13 | trait TestPrimitiveResponseMutationInput extends js.Object { 14 | val a: String 15 | } 16 | 17 | object TestPrimitiveResponseMutationInput { 18 | def apply( 19 | a: String 20 | ): TestPrimitiveResponseMutationInput = 21 | js.Dynamic.literal( 22 | a = a 23 | ).asInstanceOf[TestPrimitiveResponseMutationInput] 24 | } 25 | 26 | @js.native 27 | trait TestPrimitiveResponseMutation extends js.Object { 28 | val primitiveResponse: String 29 | } 30 | 31 | object TestPrimitiveResponseMutation extends _root_.com.goodcover.relay.MutationTaggedNode[TestPrimitiveResponseMutationInput, TestPrimitiveResponseMutation] { 32 | type Ctor[T] = T 33 | 34 | def newInput( 35 | a: String 36 | ): _root_.relay.generated.TestPrimitiveResponseMutationInput = 37 | _root_.relay.generated.TestPrimitiveResponseMutationInput( 38 | a 39 | ) 40 | 41 | type Query = _root_.com.goodcover.relay.ConcreteRequest 42 | 43 | @js.native 44 | @JSImport("__generated__/TestPrimitiveResponseMutation.graphql", JSImport.Default) 45 | private object node extends js.Object 46 | 47 | lazy val query: Query = node.asInstanceOf[Query] 48 | 49 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 50 | } 51 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/expected/TestPrimitiveVariableMutation.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | mutation TestPrimitiveVariableMutation($a: String!) { 9 | primitiveVariable(a: $a) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestPrimitiveVariableMutationInput extends js.Object { 16 | val a: String 17 | } 18 | 19 | object TestPrimitiveVariableMutationInput { 20 | def apply( 21 | a: String 22 | ): TestPrimitiveVariableMutationInput = 23 | js.Dynamic.literal( 24 | a = a 25 | ).asInstanceOf[TestPrimitiveVariableMutationInput] 26 | } 27 | 28 | @js.native 29 | trait TestPrimitiveVariableMutation extends js.Object { 30 | val primitiveVariable: TestPrimitiveVariableMutation.PrimitiveVariable 31 | } 32 | 33 | object TestPrimitiveVariableMutation extends _root_.com.goodcover.relay.MutationTaggedNode[TestPrimitiveVariableMutationInput, TestPrimitiveVariableMutation] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait PrimitiveVariable extends js.Object { 38 | val id: String 39 | } 40 | 41 | def newInput( 42 | a: String 43 | ): _root_.relay.generated.TestPrimitiveVariableMutationInput = 44 | _root_.relay.generated.TestPrimitiveVariableMutationInput( 45 | a 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestPrimitiveVariableMutation.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/src/main/resources/graphql/Schema.graphqls: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | mutation: Mutation 4 | } 5 | 6 | type Query {} 7 | 8 | type Mutation { 9 | noVariables: Node! 10 | objectVariable(input: Input): Node! 11 | nestedObjectVariable(nested: Nested): Node! 12 | primitiveVariable(a: String): Node! 13 | listVariable(as: [String]): Node! 14 | multipleVariables(a: String, b: String): Node! 15 | primitiveResponse(a: String): String! 16 | optionalPrimitiveResponse(a: String): String 17 | listResponse(a: String): [String!]! 18 | } 19 | 20 | input Input { 21 | a: String! 22 | } 23 | 24 | input Nested { 25 | input: Input! 26 | } 27 | 28 | type Node { 29 | id: ID! 30 | } 31 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/mutation/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | mutation TestNoVariablesMutation { 2 | noVariables { 3 | id 4 | } 5 | } 6 | 7 | mutation TestObjectVariableMutation($input: Input!) { 8 | objectVariable(input: $input) { 9 | id 10 | } 11 | } 12 | 13 | mutation TestOptionalObjectVariableMutation($input: Input) { 14 | objectVariable(input: $input) { 15 | id 16 | } 17 | } 18 | 19 | mutation TestNestedObjectVariableMutation($nested: Nested) { 20 | nestedObjectVariable(nested: $nested) { 21 | id 22 | } 23 | } 24 | 25 | mutation TestPrimitiveVariableMutation($a: String!) { 26 | primitiveVariable(a: $a) { 27 | id 28 | } 29 | } 30 | 31 | mutation TestOptionalPrimitiveVariableMutation($a: String) { 32 | primitiveVariable(a: $a) { 33 | id 34 | } 35 | } 36 | 37 | mutation TestListVariableMutation($as: [String!]!) { 38 | listVariable(as: $as) { 39 | id 40 | } 41 | } 42 | 43 | mutation TestOptionalListVariableMutation($as: [String!]) { 44 | listVariable(as: $as) { 45 | id 46 | } 47 | } 48 | 49 | mutation TestMultipleVariablesMutation($a: String!, $b: String!) { 50 | multipleVariables(a: $a, b: $b) { 51 | id 52 | } 53 | } 54 | 55 | mutation TestPrimitiveResponseMutation($a: String!) { 56 | primitiveResponse(a: $a) 57 | } 58 | 59 | mutation TestOptionalPrimitiveResponseMutation($a: String!) { 60 | optionalPrimitiveResponse(a: $a) 61 | } 62 | 63 | mutation TestListResponseMutation($a: String!) { 64 | listResponse(a: $a) 65 | } 66 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | // Avoid picking up the expected files in the unmanagedSources. 26 | unmanagedSources / excludeFilter ~= (_ || "*.scala") 27 | 28 | logLevel := Level.Debug 29 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/expected/Input.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | 6 | /* 7 | input Input { 8 | a: String! 9 | } 10 | */ 11 | 12 | trait Input extends js.Object { 13 | val a: String 14 | } 15 | 16 | object Input { 17 | def apply( 18 | a: String 19 | ): Input = 20 | js.Dynamic.literal( 21 | a = a 22 | ).asInstanceOf[Input] 23 | } 24 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/expected/Nested.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | 6 | /* 7 | input Nested { 8 | input: Input! 9 | } 10 | */ 11 | 12 | trait Nested extends js.Object { 13 | val input: Input 14 | } 15 | 16 | object Nested { 17 | def apply( 18 | input: Input 19 | ): Nested = 20 | js.Dynamic.literal( 21 | input = input 22 | ).asInstanceOf[Nested] 23 | } 24 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/expected/TestListResponseQuery.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | query TestListResponseQuery($a: String!) { 9 | listResponse(a: $a) 10 | } 11 | */ 12 | 13 | trait TestListResponseQueryInput extends js.Object { 14 | val a: String 15 | } 16 | 17 | object TestListResponseQueryInput { 18 | def apply( 19 | a: String 20 | ): TestListResponseQueryInput = 21 | js.Dynamic.literal( 22 | a = a 23 | ).asInstanceOf[TestListResponseQueryInput] 24 | } 25 | 26 | @js.native 27 | trait TestListResponseQuery extends js.Object { 28 | val listResponse: js.Array[String] 29 | } 30 | 31 | object TestListResponseQuery extends _root_.com.goodcover.relay.QueryTaggedNode[TestListResponseQueryInput, TestListResponseQuery] { 32 | type Ctor[T] = T 33 | 34 | def newInput( 35 | a: String 36 | ): _root_.relay.generated.TestListResponseQueryInput = 37 | _root_.relay.generated.TestListResponseQueryInput( 38 | a 39 | ) 40 | 41 | type Query = _root_.com.goodcover.relay.ConcreteRequest 42 | 43 | @js.native 44 | @JSImport("__generated__/TestListResponseQuery.graphql", JSImport.Default) 45 | private object node extends js.Object 46 | 47 | lazy val query: Query = node.asInstanceOf[Query] 48 | 49 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 50 | } 51 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/expected/TestListVariableQuery.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | query TestListVariableQuery($as: [String!]!) { 9 | listVariable(as: $as) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestListVariableQueryInput extends js.Object { 16 | val as: js.Array[String] 17 | } 18 | 19 | object TestListVariableQueryInput { 20 | def apply( 21 | as: js.Array[String] 22 | ): TestListVariableQueryInput = 23 | js.Dynamic.literal( 24 | as = as 25 | ).asInstanceOf[TestListVariableQueryInput] 26 | } 27 | 28 | @js.native 29 | trait TestListVariableQuery extends js.Object { 30 | val listVariable: TestListVariableQuery.ListVariable 31 | } 32 | 33 | object TestListVariableQuery extends _root_.com.goodcover.relay.QueryTaggedNode[TestListVariableQueryInput, TestListVariableQuery] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait ListVariable extends js.Object { 38 | val id: String 39 | } 40 | 41 | def newInput( 42 | as: js.Array[String] 43 | ): _root_.relay.generated.TestListVariableQueryInput = 44 | _root_.relay.generated.TestListVariableQueryInput( 45 | as 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestListVariableQuery.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/expected/TestMultipleVariablesQuery.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | query TestMultipleVariablesQuery($a: String!, $b: String!) { 9 | multipleVariables(a: $a, b: $b) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestMultipleVariablesQueryInput extends js.Object { 16 | val a: String 17 | val b: String 18 | } 19 | 20 | object TestMultipleVariablesQueryInput { 21 | def apply( 22 | a: String, 23 | b: String 24 | ): TestMultipleVariablesQueryInput = 25 | js.Dynamic.literal( 26 | a = a, 27 | b = b 28 | ).asInstanceOf[TestMultipleVariablesQueryInput] 29 | } 30 | 31 | @js.native 32 | trait TestMultipleVariablesQuery extends js.Object { 33 | val multipleVariables: TestMultipleVariablesQuery.MultipleVariables 34 | } 35 | 36 | object TestMultipleVariablesQuery extends _root_.com.goodcover.relay.QueryTaggedNode[TestMultipleVariablesQueryInput, TestMultipleVariablesQuery] { 37 | type Ctor[T] = T 38 | 39 | @js.native 40 | trait MultipleVariables extends js.Object { 41 | val id: String 42 | } 43 | 44 | def newInput( 45 | a: String, 46 | b: String 47 | ): _root_.relay.generated.TestMultipleVariablesQueryInput = 48 | _root_.relay.generated.TestMultipleVariablesQueryInput( 49 | a, 50 | b 51 | ) 52 | 53 | type Query = _root_.com.goodcover.relay.ConcreteRequest 54 | 55 | @js.native 56 | @JSImport("__generated__/TestMultipleVariablesQuery.graphql", JSImport.Default) 57 | private object node extends js.Object 58 | 59 | lazy val query: Query = node.asInstanceOf[Query] 60 | 61 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 62 | } 63 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/expected/TestNoVariablesQuery.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | query TestNoVariablesQuery { 9 | noVariables { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestNoVariablesQueryInput extends js.Object 16 | 17 | object TestNoVariablesQueryInput { 18 | def apply(): TestNoVariablesQueryInput = js.Dynamic.literal().asInstanceOf[TestNoVariablesQueryInput] 19 | } 20 | 21 | @js.native 22 | trait TestNoVariablesQuery extends js.Object { 23 | val noVariables: TestNoVariablesQuery.NoVariables 24 | } 25 | 26 | object TestNoVariablesQuery extends _root_.com.goodcover.relay.QueryTaggedNode[TestNoVariablesQueryInput, TestNoVariablesQuery] { 27 | type Ctor[T] = T 28 | 29 | @js.native 30 | trait NoVariables extends js.Object { 31 | val id: String 32 | } 33 | 34 | def newInput(): _root_.relay.generated.TestNoVariablesQueryInput = _root_.relay.generated.TestNoVariablesQueryInput() 35 | 36 | type Query = _root_.com.goodcover.relay.ConcreteRequest 37 | 38 | @js.native 39 | @JSImport("__generated__/TestNoVariablesQuery.graphql", JSImport.Default) 40 | private object node extends js.Object 41 | 42 | lazy val query: Query = node.asInstanceOf[Query] 43 | 44 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 45 | } 46 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/expected/TestObjectVariableQuery.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | query TestObjectVariableQuery($input: Input!) { 9 | objectVariable(input: $input) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestObjectVariableQueryInput extends js.Object { 16 | val input: Input 17 | } 18 | 19 | object TestObjectVariableQueryInput { 20 | def apply( 21 | input: Input 22 | ): TestObjectVariableQueryInput = 23 | js.Dynamic.literal( 24 | input = input 25 | ).asInstanceOf[TestObjectVariableQueryInput] 26 | } 27 | 28 | @js.native 29 | trait TestObjectVariableQuery extends js.Object { 30 | val objectVariable: TestObjectVariableQuery.ObjectVariable 31 | } 32 | 33 | object TestObjectVariableQuery extends _root_.com.goodcover.relay.QueryTaggedNode[TestObjectVariableQueryInput, TestObjectVariableQuery] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait ObjectVariable extends js.Object { 38 | val id: String 39 | } 40 | 41 | def newInput( 42 | input: _root_.relay.generated.Input 43 | ): _root_.relay.generated.TestObjectVariableQueryInput = 44 | _root_.relay.generated.TestObjectVariableQueryInput( 45 | input 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestObjectVariableQuery.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/expected/TestOptionalListVariableQuery.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | query TestOptionalListVariableQuery($as: [String!]) { 9 | listVariable(as: $as) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestOptionalListVariableQueryInput extends js.Object { 16 | val as: js.Array[String] | Null 17 | } 18 | 19 | object TestOptionalListVariableQueryInput { 20 | def apply( 21 | as: js.Array[String] | Null = null 22 | ): TestOptionalListVariableQueryInput = 23 | js.Dynamic.literal( 24 | as = as 25 | ).asInstanceOf[TestOptionalListVariableQueryInput] 26 | } 27 | 28 | @js.native 29 | trait TestOptionalListVariableQuery extends js.Object { 30 | val listVariable: TestOptionalListVariableQuery.ListVariable 31 | } 32 | 33 | object TestOptionalListVariableQuery extends _root_.com.goodcover.relay.QueryTaggedNode[TestOptionalListVariableQueryInput, TestOptionalListVariableQuery] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait ListVariable extends js.Object { 38 | val id: String 39 | } 40 | 41 | def newInput( 42 | as: js.Array[String] | Null = null 43 | ): _root_.relay.generated.TestOptionalListVariableQueryInput = 44 | _root_.relay.generated.TestOptionalListVariableQueryInput( 45 | as 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestOptionalListVariableQuery.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/expected/TestOptionalObjectVariableQuery.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | query TestOptionalObjectVariableQuery($input: Input) { 9 | objectVariable(input: $input) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestOptionalObjectVariableQueryInput extends js.Object { 16 | val input: Input | Null 17 | } 18 | 19 | object TestOptionalObjectVariableQueryInput { 20 | def apply( 21 | input: Input | Null = null 22 | ): TestOptionalObjectVariableQueryInput = 23 | js.Dynamic.literal( 24 | input = input 25 | ).asInstanceOf[TestOptionalObjectVariableQueryInput] 26 | } 27 | 28 | @js.native 29 | trait TestOptionalObjectVariableQuery extends js.Object { 30 | val objectVariable: TestOptionalObjectVariableQuery.ObjectVariable 31 | } 32 | 33 | object TestOptionalObjectVariableQuery extends _root_.com.goodcover.relay.QueryTaggedNode[TestOptionalObjectVariableQueryInput, TestOptionalObjectVariableQuery] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait ObjectVariable extends js.Object { 38 | val id: String 39 | } 40 | 41 | def newInput( 42 | input: _root_.relay.generated.Input | Null = null 43 | ): _root_.relay.generated.TestOptionalObjectVariableQueryInput = 44 | _root_.relay.generated.TestOptionalObjectVariableQueryInput( 45 | input 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestOptionalObjectVariableQuery.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/expected/TestOptionalPrimitiveResponseQuery.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | query TestOptionalPrimitiveResponseQuery($a: String!) { 9 | optionalPrimitiveResponse(a: $a) 10 | } 11 | */ 12 | 13 | trait TestOptionalPrimitiveResponseQueryInput extends js.Object { 14 | val a: String 15 | } 16 | 17 | object TestOptionalPrimitiveResponseQueryInput { 18 | def apply( 19 | a: String 20 | ): TestOptionalPrimitiveResponseQueryInput = 21 | js.Dynamic.literal( 22 | a = a 23 | ).asInstanceOf[TestOptionalPrimitiveResponseQueryInput] 24 | } 25 | 26 | @js.native 27 | trait TestOptionalPrimitiveResponseQuery extends js.Object { 28 | val optionalPrimitiveResponse: String | Null 29 | } 30 | 31 | object TestOptionalPrimitiveResponseQuery extends _root_.com.goodcover.relay.QueryTaggedNode[TestOptionalPrimitiveResponseQueryInput, TestOptionalPrimitiveResponseQuery] { 32 | type Ctor[T] = T 33 | 34 | def newInput( 35 | a: String 36 | ): _root_.relay.generated.TestOptionalPrimitiveResponseQueryInput = 37 | _root_.relay.generated.TestOptionalPrimitiveResponseQueryInput( 38 | a 39 | ) 40 | 41 | type Query = _root_.com.goodcover.relay.ConcreteRequest 42 | 43 | @js.native 44 | @JSImport("__generated__/TestOptionalPrimitiveResponseQuery.graphql", JSImport.Default) 45 | private object node extends js.Object 46 | 47 | lazy val query: Query = node.asInstanceOf[Query] 48 | 49 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 50 | } 51 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/expected/TestOptionalPrimitiveVariableQuery.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | query TestOptionalPrimitiveVariableQuery($a: String) { 9 | primitiveVariable(a: $a) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestOptionalPrimitiveVariableQueryInput extends js.Object { 16 | val a: String | Null 17 | } 18 | 19 | object TestOptionalPrimitiveVariableQueryInput { 20 | def apply( 21 | a: String | Null = null 22 | ): TestOptionalPrimitiveVariableQueryInput = 23 | js.Dynamic.literal( 24 | a = a 25 | ).asInstanceOf[TestOptionalPrimitiveVariableQueryInput] 26 | } 27 | 28 | @js.native 29 | trait TestOptionalPrimitiveVariableQuery extends js.Object { 30 | val primitiveVariable: TestOptionalPrimitiveVariableQuery.PrimitiveVariable 31 | } 32 | 33 | object TestOptionalPrimitiveVariableQuery extends _root_.com.goodcover.relay.QueryTaggedNode[TestOptionalPrimitiveVariableQueryInput, TestOptionalPrimitiveVariableQuery] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait PrimitiveVariable extends js.Object { 38 | val id: String 39 | } 40 | 41 | def newInput( 42 | a: String | Null = null 43 | ): _root_.relay.generated.TestOptionalPrimitiveVariableQueryInput = 44 | _root_.relay.generated.TestOptionalPrimitiveVariableQueryInput( 45 | a 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestOptionalPrimitiveVariableQuery.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/expected/TestPrimitiveResponseQuery.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | query TestPrimitiveResponseQuery($a: String!) { 9 | primitiveResponse(a: $a) 10 | } 11 | */ 12 | 13 | trait TestPrimitiveResponseQueryInput extends js.Object { 14 | val a: String 15 | } 16 | 17 | object TestPrimitiveResponseQueryInput { 18 | def apply( 19 | a: String 20 | ): TestPrimitiveResponseQueryInput = 21 | js.Dynamic.literal( 22 | a = a 23 | ).asInstanceOf[TestPrimitiveResponseQueryInput] 24 | } 25 | 26 | @js.native 27 | trait TestPrimitiveResponseQuery extends js.Object { 28 | val primitiveResponse: String 29 | } 30 | 31 | object TestPrimitiveResponseQuery extends _root_.com.goodcover.relay.QueryTaggedNode[TestPrimitiveResponseQueryInput, TestPrimitiveResponseQuery] { 32 | type Ctor[T] = T 33 | 34 | def newInput( 35 | a: String 36 | ): _root_.relay.generated.TestPrimitiveResponseQueryInput = 37 | _root_.relay.generated.TestPrimitiveResponseQueryInput( 38 | a 39 | ) 40 | 41 | type Query = _root_.com.goodcover.relay.ConcreteRequest 42 | 43 | @js.native 44 | @JSImport("__generated__/TestPrimitiveResponseQuery.graphql", JSImport.Default) 45 | private object node extends js.Object 46 | 47 | lazy val query: Query = node.asInstanceOf[Query] 48 | 49 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 50 | } 51 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/expected/TestPrimitiveVariableQuery.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | query TestPrimitiveVariableQuery($a: String!) { 9 | primitiveVariable(a: $a) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestPrimitiveVariableQueryInput extends js.Object { 16 | val a: String 17 | } 18 | 19 | object TestPrimitiveVariableQueryInput { 20 | def apply( 21 | a: String 22 | ): TestPrimitiveVariableQueryInput = 23 | js.Dynamic.literal( 24 | a = a 25 | ).asInstanceOf[TestPrimitiveVariableQueryInput] 26 | } 27 | 28 | @js.native 29 | trait TestPrimitiveVariableQuery extends js.Object { 30 | val primitiveVariable: TestPrimitiveVariableQuery.PrimitiveVariable 31 | } 32 | 33 | object TestPrimitiveVariableQuery extends _root_.com.goodcover.relay.QueryTaggedNode[TestPrimitiveVariableQueryInput, TestPrimitiveVariableQuery] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait PrimitiveVariable extends js.Object { 38 | val id: String 39 | } 40 | 41 | def newInput( 42 | a: String 43 | ): _root_.relay.generated.TestPrimitiveVariableQueryInput = 44 | _root_.relay.generated.TestPrimitiveVariableQueryInput( 45 | a 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestPrimitiveVariableQuery.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/src/main/resources/graphql/Schema.graphqls: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | mutation: Mutation 4 | subscription: Subscription 5 | } 6 | 7 | type Query { 8 | noVariables: Node! 9 | objectVariable(input: Input): Node! 10 | nestedObjectVariable(nested: Nested): Node! 11 | primitiveVariable(a: String): Node! 12 | listVariable(as: [String]): Node! 13 | multipleVariables(a: String, b: String): Node! 14 | primitiveResponse(a: String): String! 15 | optionalPrimitiveResponse(a: String): String 16 | listResponse(a: String): [String!]! 17 | } 18 | 19 | input Input { 20 | a: String! 21 | } 22 | 23 | input Nested { 24 | input: Input! 25 | } 26 | 27 | type Node { 28 | id: ID! 29 | } 30 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/query/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | query TestNoVariablesQuery { 2 | noVariables { 3 | id 4 | } 5 | } 6 | 7 | query TestObjectVariableQuery($input: Input!) { 8 | objectVariable(input: $input) { 9 | id 10 | } 11 | } 12 | 13 | query TestOptionalObjectVariableQuery($input: Input) { 14 | objectVariable(input: $input) { 15 | id 16 | } 17 | } 18 | 19 | query TestNestedObjectVariableQuery($nested: Nested) { 20 | nestedObjectVariable(nested: $nested) { 21 | id 22 | } 23 | } 24 | 25 | query TestPrimitiveVariableQuery($a: String!) { 26 | primitiveVariable(a: $a) { 27 | id 28 | } 29 | } 30 | 31 | query TestOptionalPrimitiveVariableQuery($a: String) { 32 | primitiveVariable(a: $a) { 33 | id 34 | } 35 | } 36 | 37 | query TestListVariableQuery($as: [String!]!) { 38 | listVariable(as: $as) { 39 | id 40 | } 41 | } 42 | 43 | query TestOptionalListVariableQuery($as: [String!]) { 44 | listVariable(as: $as) { 45 | id 46 | } 47 | } 48 | 49 | query TestMultipleVariablesQuery($a: String!, $b: String!) { 50 | multipleVariables(a: $a, b: $b) { 51 | id 52 | } 53 | } 54 | 55 | query TestPrimitiveResponseQuery($a: String!) { 56 | primitiveResponse(a: $a) 57 | } 58 | 59 | query TestOptionalPrimitiveResponseQuery($a: String!) { 60 | optionalPrimitiveResponse(a: $a) 61 | } 62 | 63 | query TestListResponseQuery($a: String!) { 64 | listResponse(a: $a) 65 | } 66 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | // Avoid picking up the expected files in the unmanagedSources. 26 | unmanagedSources / excludeFilter ~= (_ || "*.scala") 27 | 28 | logLevel := Level.Debug 29 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/Args.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | */ 9 | 10 | trait ArgsInput extends js.Object { 11 | val b: String | Null 12 | } 13 | 14 | object ArgsInput { 15 | def apply( 16 | b: String | Null = null 17 | ): ArgsInput = 18 | js.Dynamic.literal( 19 | b = b 20 | ).asInstanceOf[ArgsInput] 21 | } 22 | 23 | @js.native 24 | trait Args extends js.Object 25 | 26 | object Args extends _root_.com.goodcover.relay.QueryTaggedNode[ArgsInput, Args] { 27 | type Ctor[T] = T 28 | 29 | implicit class Args2Test_fragment2Ref(f: Args) extends _root_.com.goodcover.relay.CastToFragmentRef[Args, Test_fragment2](f) { 30 | def toTest_fragment2: _root_.com.goodcover.relay.FragmentRef[Test_fragment2] = castToRef 31 | } 32 | 33 | def newInput( 34 | b: String | Null = null 35 | ): _root_.relay.generated.ArgsInput = 36 | _root_.relay.generated.ArgsInput( 37 | b 38 | ) 39 | 40 | type Query = _root_.com.goodcover.relay.ConcreteRequest 41 | 42 | @js.native 43 | @JSImport("__generated__/Args.graphql", JSImport.Default) 44 | private object node extends js.Object 45 | 46 | lazy val query: Query = node.asInstanceOf[Query] 47 | 48 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 49 | } 50 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/ArgsOfSpread.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | */ 9 | 10 | trait ArgsOfSpreadInput extends js.Object { 11 | val b: String | Null 12 | } 13 | 14 | object ArgsOfSpreadInput { 15 | def apply( 16 | b: String | Null = null 17 | ): ArgsOfSpreadInput = 18 | js.Dynamic.literal( 19 | b = b 20 | ).asInstanceOf[ArgsOfSpreadInput] 21 | } 22 | 23 | @js.native 24 | trait ArgsOfSpread extends js.Object 25 | 26 | object ArgsOfSpread extends _root_.com.goodcover.relay.QueryTaggedNode[ArgsOfSpreadInput, ArgsOfSpread] { 27 | type Ctor[T] = T 28 | 29 | implicit class ArgsOfSpread2Test_fragment6Ref(f: ArgsOfSpread) extends _root_.com.goodcover.relay.CastToFragmentRef[ArgsOfSpread, Test_fragment6](f) { 30 | def toTest_fragment6: _root_.com.goodcover.relay.FragmentRef[Test_fragment6] = castToRef 31 | } 32 | 33 | def newInput( 34 | b: String | Null = null 35 | ): _root_.relay.generated.ArgsOfSpreadInput = 36 | _root_.relay.generated.ArgsOfSpreadInput( 37 | b 38 | ) 39 | 40 | type Query = _root_.com.goodcover.relay.ConcreteRequest 41 | 42 | @js.native 43 | @JSImport("__generated__/ArgsOfSpread.graphql", JSImport.Default) 44 | private object node extends js.Object 45 | 46 | lazy val query: Query = node.asInstanceOf[Query] 47 | 48 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 49 | } 50 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/ImplicitNodeArgs.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | */ 9 | 10 | trait ImplicitNodeArgsInput extends js.Object { 11 | val id: String 12 | } 13 | 14 | object ImplicitNodeArgsInput { 15 | def apply( 16 | id: String 17 | ): ImplicitNodeArgsInput = 18 | js.Dynamic.literal( 19 | id = id 20 | ).asInstanceOf[ImplicitNodeArgsInput] 21 | } 22 | 23 | @js.native 24 | trait ImplicitNodeArgs extends js.Object 25 | 26 | object ImplicitNodeArgs extends _root_.com.goodcover.relay.QueryTaggedNode[ImplicitNodeArgsInput, ImplicitNodeArgs] { 27 | type Ctor[T] = T 28 | 29 | implicit class ImplicitNodeArgs2Test_fragment5Ref(f: ImplicitNodeArgs) extends _root_.com.goodcover.relay.CastToFragmentRef[ImplicitNodeArgs, Test_fragment5](f) { 30 | def toTest_fragment5: _root_.com.goodcover.relay.FragmentRef[Test_fragment5] = castToRef 31 | } 32 | 33 | def newInput( 34 | id: String 35 | ): _root_.relay.generated.ImplicitNodeArgsInput = 36 | _root_.relay.generated.ImplicitNodeArgsInput( 37 | id 38 | ) 39 | 40 | type Query = _root_.com.goodcover.relay.ConcreteRequest 41 | 42 | @js.native 43 | @JSImport("__generated__/ImplicitNodeArgs.graphql", JSImport.Default) 44 | private object node extends js.Object 45 | 46 | lazy val query: Query = node.asInstanceOf[Query] 47 | 48 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 49 | } 50 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/NestedArgs.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | */ 9 | 10 | trait NestedArgsInput extends js.Object { 11 | val b: String | Null 12 | } 13 | 14 | object NestedArgsInput { 15 | def apply( 16 | b: String | Null = null 17 | ): NestedArgsInput = 18 | js.Dynamic.literal( 19 | b = b 20 | ).asInstanceOf[NestedArgsInput] 21 | } 22 | 23 | @js.native 24 | trait NestedArgs extends js.Object 25 | 26 | object NestedArgs extends _root_.com.goodcover.relay.QueryTaggedNode[NestedArgsInput, NestedArgs] { 27 | type Ctor[T] = T 28 | 29 | implicit class NestedArgs2Test_fragment3Ref(f: NestedArgs) extends _root_.com.goodcover.relay.CastToFragmentRef[NestedArgs, Test_fragment3](f) { 30 | def toTest_fragment3: _root_.com.goodcover.relay.FragmentRef[Test_fragment3] = castToRef 31 | } 32 | 33 | def newInput( 34 | b: String | Null = null 35 | ): _root_.relay.generated.NestedArgsInput = 36 | _root_.relay.generated.NestedArgsInput( 37 | b 38 | ) 39 | 40 | type Query = _root_.com.goodcover.relay.ConcreteRequest 41 | 42 | @js.native 43 | @JSImport("__generated__/NestedArgs.graphql", JSImport.Default) 44 | private object node extends js.Object 45 | 46 | lazy val query: Query = node.asInstanceOf[Query] 47 | 48 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 49 | } 50 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/NoArgs.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | */ 9 | 10 | trait NoArgsInput extends js.Object 11 | 12 | object NoArgsInput { 13 | def apply(): NoArgsInput = js.Dynamic.literal().asInstanceOf[NoArgsInput] 14 | } 15 | 16 | @js.native 17 | trait NoArgs extends js.Object 18 | 19 | object NoArgs extends _root_.com.goodcover.relay.QueryTaggedNode[NoArgsInput, NoArgs] { 20 | type Ctor[T] = T 21 | 22 | implicit class NoArgs2Test_fragmentRef(f: NoArgs) extends _root_.com.goodcover.relay.CastToFragmentRef[NoArgs, Test_fragment](f) { 23 | def toTest_fragment: _root_.com.goodcover.relay.FragmentRef[Test_fragment] = castToRef 24 | } 25 | 26 | def newInput(): _root_.relay.generated.NoArgsInput = _root_.relay.generated.NoArgsInput() 27 | 28 | type Query = _root_.com.goodcover.relay.ConcreteRequest 29 | 30 | @js.native 31 | @JSImport("__generated__/NoArgs.graphql", JSImport.Default) 32 | private object node extends js.Object 33 | 34 | lazy val query: Query = node.asInstanceOf[Query] 35 | 36 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 37 | } 38 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/ObjectArgs.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | */ 9 | 10 | trait ObjectArgsInput extends js.Object { 11 | val thing: Thing | Null 12 | } 13 | 14 | object ObjectArgsInput { 15 | def apply( 16 | thing: Thing | Null = null 17 | ): ObjectArgsInput = 18 | js.Dynamic.literal( 19 | thing = thing 20 | ).asInstanceOf[ObjectArgsInput] 21 | } 22 | 23 | @js.native 24 | trait ObjectArgs extends js.Object 25 | 26 | object ObjectArgs extends _root_.com.goodcover.relay.QueryTaggedNode[ObjectArgsInput, ObjectArgs] { 27 | type Ctor[T] = T 28 | 29 | implicit class ObjectArgs2Test_fragment4Ref(f: ObjectArgs) extends _root_.com.goodcover.relay.CastToFragmentRef[ObjectArgs, Test_fragment4](f) { 30 | def toTest_fragment4: _root_.com.goodcover.relay.FragmentRef[Test_fragment4] = castToRef 31 | } 32 | 33 | def newInput( 34 | thing: _root_.relay.generated.Thing | Null = null 35 | ): _root_.relay.generated.ObjectArgsInput = 36 | _root_.relay.generated.ObjectArgsInput( 37 | thing 38 | ) 39 | 40 | type Query = _root_.com.goodcover.relay.ConcreteRequest 41 | 42 | @js.native 43 | @JSImport("__generated__/ObjectArgs.graphql", JSImport.Default) 44 | private object node extends js.Object 45 | 46 | lazy val query: Query = node.asInstanceOf[Query] 47 | 48 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 49 | } 50 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/Stuff.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | 6 | /* 7 | input Stuff { 8 | junk: String 9 | } 10 | */ 11 | 12 | trait Stuff extends js.Object { 13 | val junk: String | Null 14 | } 15 | 16 | object Stuff { 17 | def apply( 18 | junk: String | Null = null 19 | ): Stuff = 20 | js.Dynamic.literal( 21 | junk = junk 22 | ).asInstanceOf[Stuff] 23 | } 24 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/Test_fragment.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_fragment on Query @refetchable(queryName: "NoArgs") { 9 | foo { 10 | bar 11 | } 12 | } 13 | */ 14 | 15 | @js.native 16 | trait Test_fragment extends js.Object { 17 | val foo: Test_fragment.Foo 18 | } 19 | 20 | object Test_fragment extends _root_.com.goodcover.relay.FragmentRefetchableTaggedNode[Test_fragment, NoArgsInput, NoArgs] { 21 | type Ctor[T] = T 22 | 23 | @js.native 24 | trait Foo extends js.Object { 25 | val bar: String | Null 26 | } 27 | 28 | type Query = _root_.com.goodcover.relay.ReaderFragment[Ctor, Out] 29 | 30 | @js.native 31 | @JSImport("__generated__/Test_fragment.graphql", JSImport.Default) 32 | private object node extends js.Object 33 | 34 | lazy val query: Query = node.asInstanceOf[Query] 35 | 36 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 37 | } 38 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/Test_fragment2.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_fragment2 on Query @refetchable(queryName: "Args") { 9 | oneArg(a: $b) { 10 | bar 11 | } 12 | } 13 | */ 14 | 15 | @js.native 16 | trait Test_fragment2 extends js.Object { 17 | val oneArg: Test_fragment2.OneArg 18 | } 19 | 20 | object Test_fragment2 extends _root_.com.goodcover.relay.FragmentRefetchableTaggedNode[Test_fragment2, ArgsInput, Args] { 21 | type Ctor[T] = T 22 | 23 | @js.native 24 | trait OneArg extends js.Object { 25 | val bar: String | Null 26 | } 27 | 28 | type Query = _root_.com.goodcover.relay.ReaderFragment[Ctor, Out] 29 | 30 | @js.native 31 | @JSImport("__generated__/Test_fragment2.graphql", JSImport.Default) 32 | private object node extends js.Object 33 | 34 | lazy val query: Query = node.asInstanceOf[Query] 35 | 36 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 37 | } 38 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/Test_fragment3.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_fragment3 on Query @refetchable(queryName: "NestedArgs") { 9 | foo { 10 | args { 11 | oneArg(a: $b) { 12 | bar 13 | } 14 | } 15 | } 16 | } 17 | */ 18 | 19 | @js.native 20 | trait Test_fragment3 extends js.Object { 21 | val foo: Test_fragment3.Foo 22 | } 23 | 24 | object Test_fragment3 extends _root_.com.goodcover.relay.FragmentRefetchableTaggedNode[Test_fragment3, NestedArgsInput, NestedArgs] { 25 | type Ctor[T] = T 26 | 27 | @js.native 28 | trait FooArgsOneArg extends js.Object { 29 | val bar: String | Null 30 | } 31 | 32 | @js.native 33 | trait FooArgs extends js.Object { 34 | val oneArg: FooArgsOneArg 35 | } 36 | 37 | @js.native 38 | trait Foo extends js.Object { 39 | val args: FooArgs | Null 40 | } 41 | 42 | type Query = _root_.com.goodcover.relay.ReaderFragment[Ctor, Out] 43 | 44 | @js.native 45 | @JSImport("__generated__/Test_fragment3.graphql", JSImport.Default) 46 | private object node extends js.Object 47 | 48 | lazy val query: Query = node.asInstanceOf[Query] 49 | 50 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 51 | } 52 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/Test_fragment4.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_fragment4 on Query @refetchable(queryName: "ObjectArgs") { 9 | objArg(thing: $thing) { 10 | bar 11 | } 12 | } 13 | */ 14 | 15 | @js.native 16 | trait Test_fragment4 extends js.Object { 17 | val objArg: Test_fragment4.ObjArg 18 | } 19 | 20 | object Test_fragment4 extends _root_.com.goodcover.relay.FragmentRefetchableTaggedNode[Test_fragment4, ObjectArgsInput, ObjectArgs] { 21 | type Ctor[T] = T 22 | 23 | @js.native 24 | trait ObjArg extends js.Object { 25 | val bar: String | Null 26 | } 27 | 28 | type Query = _root_.com.goodcover.relay.ReaderFragment[Ctor, Out] 29 | 30 | @js.native 31 | @JSImport("__generated__/Test_fragment4.graphql", JSImport.Default) 32 | private object node extends js.Object 33 | 34 | lazy val query: Query = node.asInstanceOf[Query] 35 | 36 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 37 | } 38 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/Test_fragment5.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_fragment5 on ImplicitNode @refetchable(queryName: "ImplicitNodeArgs") { 9 | name 10 | } 11 | */ 12 | 13 | @js.native 14 | trait Test_fragment5 extends js.Object { 15 | val name: String 16 | } 17 | 18 | object Test_fragment5 extends _root_.com.goodcover.relay.FragmentRefetchableTaggedNode[Test_fragment5, ImplicitNodeArgsInput, ImplicitNodeArgs] { 19 | type Ctor[T] = T 20 | 21 | type Query = _root_.com.goodcover.relay.ReaderFragment[Ctor, Out] 22 | 23 | @js.native 24 | @JSImport("__generated__/Test_fragment5.graphql", JSImport.Default) 25 | private object node extends js.Object 26 | 27 | lazy val query: Query = node.asInstanceOf[Query] 28 | 29 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 30 | } 31 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/Test_fragment6.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_fragment6 on Query @refetchable(queryName: "ArgsOfSpread") { 9 | foo { 10 | args { 11 | ...Test_args 12 | } 13 | } 14 | } 15 | */ 16 | 17 | @js.native 18 | trait Test_fragment6 extends js.Object { 19 | val foo: Test_fragment6.Foo 20 | } 21 | 22 | object Test_fragment6 extends _root_.com.goodcover.relay.FragmentRefetchableTaggedNode[Test_fragment6, ArgsOfSpreadInput, ArgsOfSpread] { 23 | type Ctor[T] = T 24 | 25 | @js.native 26 | trait FooArgs extends js.Object 27 | 28 | @js.native 29 | trait Foo extends js.Object { 30 | val args: FooArgs | Null 31 | } 32 | 33 | implicit class FooArgs2Test_argsRef(f: FooArgs) extends _root_.com.goodcover.relay.CastToFragmentRef[FooArgs, Test_args](f) { 34 | def toTest_args: _root_.com.goodcover.relay.FragmentRef[Test_args] = castToRef 35 | } 36 | 37 | type Query = _root_.com.goodcover.relay.ReaderFragment[Ctor, Out] 38 | 39 | @js.native 40 | @JSImport("__generated__/Test_fragment6.graphql", JSImport.Default) 41 | private object node extends js.Object 42 | 43 | lazy val query: Query = node.asInstanceOf[Query] 44 | 45 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 46 | } 47 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/Test_viewer.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_viewer on Viewer @refetchable(queryName: "ViewerQuery") { 9 | name 10 | } 11 | */ 12 | 13 | @js.native 14 | trait Test_viewer extends js.Object { 15 | val name: String 16 | } 17 | 18 | object Test_viewer extends _root_.com.goodcover.relay.FragmentRefetchableTaggedNode[Test_viewer, ViewerQueryInput, ViewerQuery] { 19 | type Ctor[T] = T 20 | 21 | type Query = _root_.com.goodcover.relay.ReaderFragment[Ctor, Out] 22 | 23 | @js.native 24 | @JSImport("__generated__/Test_viewer.graphql", JSImport.Default) 25 | private object node extends js.Object 26 | 27 | lazy val query: Query = node.asInstanceOf[Query] 28 | 29 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 30 | } 31 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/Thing.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | 6 | /* 7 | input Thing { 8 | stuff: Stuff! 9 | } 10 | */ 11 | 12 | trait Thing extends js.Object { 13 | val stuff: Stuff 14 | } 15 | 16 | object Thing { 17 | def apply( 18 | stuff: Stuff 19 | ): Thing = 20 | js.Dynamic.literal( 21 | stuff = stuff 22 | ).asInstanceOf[Thing] 23 | } 24 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/expected/ViewerQuery.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | */ 9 | 10 | trait ViewerQueryInput extends js.Object 11 | 12 | object ViewerQueryInput { 13 | def apply(): ViewerQueryInput = js.Dynamic.literal().asInstanceOf[ViewerQueryInput] 14 | } 15 | 16 | @js.native 17 | trait ViewerQuery extends js.Object 18 | 19 | object ViewerQuery extends _root_.com.goodcover.relay.QueryTaggedNode[ViewerQueryInput, ViewerQuery] { 20 | type Ctor[T] = T 21 | 22 | implicit class ViewerQuery2Test_viewerRef(f: ViewerQuery) extends _root_.com.goodcover.relay.CastToFragmentRef[ViewerQuery, Test_viewer](f) { 23 | def toTest_viewer: _root_.com.goodcover.relay.FragmentRef[Test_viewer] = castToRef 24 | } 25 | 26 | def newInput(): _root_.relay.generated.ViewerQueryInput = _root_.relay.generated.ViewerQueryInput() 27 | 28 | type Query = _root_.com.goodcover.relay.ConcreteRequest 29 | 30 | @js.native 31 | @JSImport("__generated__/ViewerQuery.graphql", JSImport.Default) 32 | private object node extends js.Object 33 | 34 | lazy val query: Query = node.asInstanceOf[Query] 35 | 36 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 37 | } 38 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/src/main/resources/graphql/Schema.graphqls: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | } 4 | 5 | type Query { 6 | foo: Foo! 7 | oneArg(a: String): Foo! 8 | objArg(thing: Thing): Foo! 9 | node(nodeID: ID!): Node 10 | viewer: Viewer 11 | } 12 | 13 | interface Node { 14 | id: ID! 15 | } 16 | 17 | type Foo { 18 | bar: String 19 | args: Args 20 | } 21 | 22 | type Args { 23 | oneArg(a: String): Foo! 24 | objArg(thing: Thing): Foo! 25 | } 26 | 27 | input Thing { 28 | stuff: Stuff! 29 | } 30 | 31 | input Stuff { 32 | junk: String 33 | } 34 | 35 | interface ImplicitNode { 36 | id: ID! 37 | name: String! 38 | } 39 | 40 | type Viewer { 41 | name: String! 42 | } 43 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/refetchable/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | fragment Test_fragment on Query @refetchable(queryName: "NoArgs") { 2 | foo { 3 | bar 4 | } 5 | } 6 | 7 | fragment Test_fragment2 on Query @refetchable(queryName: "Args") { 8 | oneArg(a: $b) { 9 | bar 10 | } 11 | } 12 | 13 | fragment Test_fragment3 on Query @refetchable(queryName: "NestedArgs") { 14 | foo { 15 | args { 16 | oneArg(a: $b) { 17 | bar 18 | } 19 | } 20 | } 21 | } 22 | 23 | fragment Test_fragment4 on Query @refetchable(queryName: "ObjectArgs") { 24 | objArg(thing: $thing) { 25 | bar 26 | } 27 | } 28 | 29 | fragment Test_fragment5 on ImplicitNode @refetchable(queryName: "ImplicitNodeArgs") { 30 | name 31 | } 32 | 33 | fragment Test_args on Args { 34 | oneArg(a: $b) { 35 | bar 36 | } 37 | } 38 | 39 | fragment Test_fragment6 on Query @refetchable(queryName: "ArgsOfSpread") { 40 | foo { 41 | args { 42 | ...Test_args 43 | } 44 | } 45 | } 46 | 47 | fragment Test_viewer on Viewer @refetchable(queryName: "ViewerQuery") { 48 | name 49 | } 50 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-client-type/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | // Avoid picking up the expected files in the unmanagedSources. 26 | unmanagedSources / excludeFilter ~= (_ || "*.scala") 27 | 28 | logLevel := Level.Debug 29 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-client-type/expected/ClientTypeNestedInput.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | 6 | /* 7 | input ClientTypeNestedInput { 8 | nested: String! @scalajs(clientType: "Nested") 9 | } 10 | */ 11 | 12 | trait ClientTypeNestedInput extends js.Object { 13 | val nested: String[Nested] 14 | } 15 | 16 | object ClientTypeNestedInput { 17 | def apply( 18 | nested: String[Nested] 19 | ): ClientTypeNestedInput = 20 | js.Dynamic.literal( 21 | nested = nested 22 | ).asInstanceOf[ClientTypeNestedInput] 23 | } 24 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-client-type/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-client-type/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-client-type/src/main/resources/graphql/Schema.graphqls: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | } 4 | 5 | type Query { 6 | clientType(input: ClientTypeInput): ClientTypeOutput 7 | } 8 | 9 | input ClientTypeInput { 10 | required: String! @scalajs(clientType: "Required") 11 | optional: String @scalajs(clientType: "Optional") 12 | requiredListRequiredElements: [String!]! @scalajs(clientType: "RequiredListRequiredElements") 13 | requiredListOptionalElements: [String]! @scalajs(clientType: "RequiredListOptionalElements") 14 | optionalListRequiredElements: [String!] @scalajs(clientType: "OptionalListRequiredElements") 15 | optionalListOptionalElements: [String] @scalajs(clientType: "OptionalListOptionalElements") 16 | nested: ClientTypeNestedInput! 17 | } 18 | 19 | input ClientTypeNestedInput { 20 | nested: String! @scalajs(clientType: "Nested") 21 | } 22 | 23 | type ClientTypeOutput { 24 | required: String! @scalajs(clientType: "Required") 25 | optional: String @scalajs(clientType: "Optional") 26 | requiredListRequiredElements: [String!]! @scalajs(clientType: "RequiredListRequiredElements") 27 | requiredListOptionalElements: [String]! @scalajs(clientType: "RequiredListOptionalElements") 28 | optionalListRequiredElements: [String!] @scalajs(clientType: "OptionalListRequiredElements") 29 | optionalListOptionalElements: [String] @scalajs(clientType: "OptionalListOptionalElements") 30 | object: ClientTypeNestedObject! 31 | interface: ClientTypeNestedInterface! 32 | } 33 | 34 | type ClientTypeNestedObject { 35 | required: String! @scalajs(clientType: "Object") 36 | } 37 | 38 | interface ClientTypeNestedInterface { 39 | required: String! @scalajs(clientType: "Interface") 40 | } 41 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-client-type/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | query TestQuery($input: ClientTypeInput!) { 2 | clientType(input: $input) { 3 | required 4 | optional 5 | requiredListRequiredElements 6 | requiredListOptionalElements 7 | optionalListRequiredElements 8 | optionalListOptionalElements 9 | object { 10 | required 11 | } 12 | interface { 13 | required 14 | } 15 | } 16 | } 17 | 18 | fragment Test_fragment on ClientTypeOutput { 19 | required 20 | optional 21 | requiredListRequiredElements 22 | requiredListOptionalElements 23 | optionalListRequiredElements 24 | optionalListOptionalElements 25 | object { 26 | required 27 | } 28 | interface { 29 | required 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-client-type/test: -------------------------------------------------------------------------------- 1 | > relayConvert 2 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/TestQuery.scala expected/TestQuery.scala 3 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/ClientTypeInput.scala expected/ClientTypeInput.scala 4 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/ClientTypeNestedInput.scala expected/ClientTypeNestedInput.scala 5 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/Test_fragment.scala expected/Test_fragment.scala 6 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-extends/Test_fragment.expected.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_fragment on Foo { 9 | bar @scalajs(extends: "ThingamyWhatsit") { 10 | baz 11 | } 12 | } 13 | */ 14 | 15 | @js.native 16 | trait Test_fragment extends js.Object { 17 | val bar: Test_fragment.Bar 18 | } 19 | 20 | object Test_fragment extends _root_.com.goodcover.relay.FragmentTaggedNode[Test_fragment] { 21 | type Ctor[T] = T 22 | 23 | @js.native 24 | trait Bar extends ThingamyWhatsit { 25 | val baz: String 26 | } 27 | 28 | type Query = _root_.com.goodcover.relay.ReaderFragment[Ctor, Out] 29 | 30 | @js.native 31 | @JSImport("__generated__/Test_fragment.graphql", JSImport.Default) 32 | private object node extends js.Object 33 | 34 | lazy val query: Query = node.asInstanceOf[Query] 35 | 36 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 37 | } 38 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-extends/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | // Avoid picking up the expected files in the unmanagedSources. 26 | unmanagedSources / excludeFilter ~= (_ || "*.scala") 27 | 28 | logLevel := Level.Debug 29 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-extends/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-extends/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-extends/src/main/resources/graphql/Schema.graphqls: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | } 4 | 5 | type Query { 6 | foo: Foo! 7 | } 8 | 9 | type Foo { 10 | bar: Bar! 11 | } 12 | 13 | type Bar { 14 | baz: String! 15 | } 16 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-extends/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | fragment Test_fragment on Foo { 2 | bar @scalajs(extends: "ThingamyWhatsit") { 3 | baz 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/scalajs-directive-extends/test: -------------------------------------------------------------------------------- 1 | > relayConvert 2 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/Test_fragment.scala Test_fragment.expected.scala 3 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | // Avoid picking up the expected files in the unmanagedSources. 26 | unmanagedSources / excludeFilter ~= (_ || "*.scala") 27 | 28 | logLevel := Level.Debug 29 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/expected/Input.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | 6 | /* 7 | input Input { 8 | a: String! 9 | } 10 | */ 11 | 12 | trait Input extends js.Object { 13 | val a: String 14 | } 15 | 16 | object Input { 17 | def apply( 18 | a: String 19 | ): Input = 20 | js.Dynamic.literal( 21 | a = a 22 | ).asInstanceOf[Input] 23 | } 24 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/expected/Nested.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | 6 | /* 7 | input Nested { 8 | input: Input! 9 | } 10 | */ 11 | 12 | trait Nested extends js.Object { 13 | val input: Input 14 | } 15 | 16 | object Nested { 17 | def apply( 18 | input: Input 19 | ): Nested = 20 | js.Dynamic.literal( 21 | input = input 22 | ).asInstanceOf[Nested] 23 | } 24 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/expected/TestListResponseSubscription.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | subscription TestListResponseSubscription($a: String!) { 9 | listResponse(a: $a) 10 | } 11 | */ 12 | 13 | trait TestListResponseSubscriptionInput extends js.Object { 14 | val a: String 15 | } 16 | 17 | object TestListResponseSubscriptionInput { 18 | def apply( 19 | a: String 20 | ): TestListResponseSubscriptionInput = 21 | js.Dynamic.literal( 22 | a = a 23 | ).asInstanceOf[TestListResponseSubscriptionInput] 24 | } 25 | 26 | @js.native 27 | trait TestListResponseSubscription extends js.Object { 28 | val listResponse: js.Array[String] 29 | } 30 | 31 | object TestListResponseSubscription extends _root_.com.goodcover.relay.SubscriptionTaggedNode[TestListResponseSubscriptionInput, TestListResponseSubscription] { 32 | type Ctor[T] = T 33 | 34 | def newInput( 35 | a: String 36 | ): _root_.relay.generated.TestListResponseSubscriptionInput = 37 | _root_.relay.generated.TestListResponseSubscriptionInput( 38 | a 39 | ) 40 | 41 | type Query = _root_.com.goodcover.relay.ConcreteRequest 42 | 43 | @js.native 44 | @JSImport("__generated__/TestListResponseSubscription.graphql", JSImport.Default) 45 | private object node extends js.Object 46 | 47 | lazy val query: Query = node.asInstanceOf[Query] 48 | 49 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 50 | } 51 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/expected/TestListVariableSubscription.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | subscription TestListVariableSubscription($as: [String!]!) { 9 | listVariable(as: $as) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestListVariableSubscriptionInput extends js.Object { 16 | val as: js.Array[String] 17 | } 18 | 19 | object TestListVariableSubscriptionInput { 20 | def apply( 21 | as: js.Array[String] 22 | ): TestListVariableSubscriptionInput = 23 | js.Dynamic.literal( 24 | as = as 25 | ).asInstanceOf[TestListVariableSubscriptionInput] 26 | } 27 | 28 | @js.native 29 | trait TestListVariableSubscription extends js.Object { 30 | val listVariable: TestListVariableSubscription.ListVariable 31 | } 32 | 33 | object TestListVariableSubscription extends _root_.com.goodcover.relay.SubscriptionTaggedNode[TestListVariableSubscriptionInput, TestListVariableSubscription] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait ListVariable extends js.Object { 38 | val id: String 39 | } 40 | 41 | def newInput( 42 | as: js.Array[String] 43 | ): _root_.relay.generated.TestListVariableSubscriptionInput = 44 | _root_.relay.generated.TestListVariableSubscriptionInput( 45 | as 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestListVariableSubscription.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/expected/TestNoVariablesSubscription.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | subscription TestNoVariablesSubscription { 9 | noVariables { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestNoVariablesSubscriptionInput extends js.Object 16 | 17 | object TestNoVariablesSubscriptionInput { 18 | def apply(): TestNoVariablesSubscriptionInput = js.Dynamic.literal().asInstanceOf[TestNoVariablesSubscriptionInput] 19 | } 20 | 21 | @js.native 22 | trait TestNoVariablesSubscription extends js.Object { 23 | val noVariables: TestNoVariablesSubscription.NoVariables 24 | } 25 | 26 | object TestNoVariablesSubscription extends _root_.com.goodcover.relay.SubscriptionTaggedNode[TestNoVariablesSubscriptionInput, TestNoVariablesSubscription] { 27 | type Ctor[T] = T 28 | 29 | @js.native 30 | trait NoVariables extends js.Object { 31 | val id: String 32 | } 33 | 34 | def newInput(): _root_.relay.generated.TestNoVariablesSubscriptionInput = _root_.relay.generated.TestNoVariablesSubscriptionInput() 35 | 36 | type Query = _root_.com.goodcover.relay.ConcreteRequest 37 | 38 | @js.native 39 | @JSImport("__generated__/TestNoVariablesSubscription.graphql", JSImport.Default) 40 | private object node extends js.Object 41 | 42 | lazy val query: Query = node.asInstanceOf[Query] 43 | 44 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 45 | } 46 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/expected/TestObjectVariableSubscription.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | subscription TestObjectVariableSubscription($input: Input!) { 9 | objectVariable(input: $input) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestObjectVariableSubscriptionInput extends js.Object { 16 | val input: Input 17 | } 18 | 19 | object TestObjectVariableSubscriptionInput { 20 | def apply( 21 | input: Input 22 | ): TestObjectVariableSubscriptionInput = 23 | js.Dynamic.literal( 24 | input = input 25 | ).asInstanceOf[TestObjectVariableSubscriptionInput] 26 | } 27 | 28 | @js.native 29 | trait TestObjectVariableSubscription extends js.Object { 30 | val objectVariable: TestObjectVariableSubscription.ObjectVariable 31 | } 32 | 33 | object TestObjectVariableSubscription extends _root_.com.goodcover.relay.SubscriptionTaggedNode[TestObjectVariableSubscriptionInput, TestObjectVariableSubscription] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait ObjectVariable extends js.Object { 38 | val id: String 39 | } 40 | 41 | def newInput( 42 | input: _root_.relay.generated.Input 43 | ): _root_.relay.generated.TestObjectVariableSubscriptionInput = 44 | _root_.relay.generated.TestObjectVariableSubscriptionInput( 45 | input 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestObjectVariableSubscription.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/expected/TestOptionalPrimitiveResponseSubscription.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | subscription TestOptionalPrimitiveResponseSubscription($a: String!) { 9 | optionalPrimitiveResponse(a: $a) 10 | } 11 | */ 12 | 13 | trait TestOptionalPrimitiveResponseSubscriptionInput extends js.Object { 14 | val a: String 15 | } 16 | 17 | object TestOptionalPrimitiveResponseSubscriptionInput { 18 | def apply( 19 | a: String 20 | ): TestOptionalPrimitiveResponseSubscriptionInput = 21 | js.Dynamic.literal( 22 | a = a 23 | ).asInstanceOf[TestOptionalPrimitiveResponseSubscriptionInput] 24 | } 25 | 26 | @js.native 27 | trait TestOptionalPrimitiveResponseSubscription extends js.Object { 28 | val optionalPrimitiveResponse: String | Null 29 | } 30 | 31 | object TestOptionalPrimitiveResponseSubscription extends _root_.com.goodcover.relay.SubscriptionTaggedNode[TestOptionalPrimitiveResponseSubscriptionInput, TestOptionalPrimitiveResponseSubscription] { 32 | type Ctor[T] = T 33 | 34 | def newInput( 35 | a: String 36 | ): _root_.relay.generated.TestOptionalPrimitiveResponseSubscriptionInput = 37 | _root_.relay.generated.TestOptionalPrimitiveResponseSubscriptionInput( 38 | a 39 | ) 40 | 41 | type Query = _root_.com.goodcover.relay.ConcreteRequest 42 | 43 | @js.native 44 | @JSImport("__generated__/TestOptionalPrimitiveResponseSubscription.graphql", JSImport.Default) 45 | private object node extends js.Object 46 | 47 | lazy val query: Query = node.asInstanceOf[Query] 48 | 49 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 50 | } 51 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/expected/TestPrimitiveResponseSubscription.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | subscription TestPrimitiveResponseSubscription($a: String!) { 9 | primitiveResponse(a: $a) 10 | } 11 | */ 12 | 13 | trait TestPrimitiveResponseSubscriptionInput extends js.Object { 14 | val a: String 15 | } 16 | 17 | object TestPrimitiveResponseSubscriptionInput { 18 | def apply( 19 | a: String 20 | ): TestPrimitiveResponseSubscriptionInput = 21 | js.Dynamic.literal( 22 | a = a 23 | ).asInstanceOf[TestPrimitiveResponseSubscriptionInput] 24 | } 25 | 26 | @js.native 27 | trait TestPrimitiveResponseSubscription extends js.Object { 28 | val primitiveResponse: String 29 | } 30 | 31 | object TestPrimitiveResponseSubscription extends _root_.com.goodcover.relay.SubscriptionTaggedNode[TestPrimitiveResponseSubscriptionInput, TestPrimitiveResponseSubscription] { 32 | type Ctor[T] = T 33 | 34 | def newInput( 35 | a: String 36 | ): _root_.relay.generated.TestPrimitiveResponseSubscriptionInput = 37 | _root_.relay.generated.TestPrimitiveResponseSubscriptionInput( 38 | a 39 | ) 40 | 41 | type Query = _root_.com.goodcover.relay.ConcreteRequest 42 | 43 | @js.native 44 | @JSImport("__generated__/TestPrimitiveResponseSubscription.graphql", JSImport.Default) 45 | private object node extends js.Object 46 | 47 | lazy val query: Query = node.asInstanceOf[Query] 48 | 49 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 50 | } 51 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/expected/TestPrimitiveVariableSubscription.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | subscription TestPrimitiveVariableSubscription($a: String!) { 9 | primitiveVariable(a: $a) { 10 | id 11 | } 12 | } 13 | */ 14 | 15 | trait TestPrimitiveVariableSubscriptionInput extends js.Object { 16 | val a: String 17 | } 18 | 19 | object TestPrimitiveVariableSubscriptionInput { 20 | def apply( 21 | a: String 22 | ): TestPrimitiveVariableSubscriptionInput = 23 | js.Dynamic.literal( 24 | a = a 25 | ).asInstanceOf[TestPrimitiveVariableSubscriptionInput] 26 | } 27 | 28 | @js.native 29 | trait TestPrimitiveVariableSubscription extends js.Object { 30 | val primitiveVariable: TestPrimitiveVariableSubscription.PrimitiveVariable 31 | } 32 | 33 | object TestPrimitiveVariableSubscription extends _root_.com.goodcover.relay.SubscriptionTaggedNode[TestPrimitiveVariableSubscriptionInput, TestPrimitiveVariableSubscription] { 34 | type Ctor[T] = T 35 | 36 | @js.native 37 | trait PrimitiveVariable extends js.Object { 38 | val id: String 39 | } 40 | 41 | def newInput( 42 | a: String 43 | ): _root_.relay.generated.TestPrimitiveVariableSubscriptionInput = 44 | _root_.relay.generated.TestPrimitiveVariableSubscriptionInput( 45 | a 46 | ) 47 | 48 | type Query = _root_.com.goodcover.relay.ConcreteRequest 49 | 50 | @js.native 51 | @JSImport("__generated__/TestPrimitiveVariableSubscription.graphql", JSImport.Default) 52 | private object node extends js.Object 53 | 54 | lazy val query: Query = node.asInstanceOf[Query] 55 | 56 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 57 | } 58 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/src/main/resources/graphql/Schema.graphqls: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | subscription: Subscription 4 | } 5 | 6 | type Query { 7 | noVariables: Node! 8 | } 9 | 10 | type Subscription { 11 | noVariables: Node! 12 | objectVariable(input: Input): Node! 13 | nestedObjectVariable(nested: Nested): Node! 14 | primitiveVariable(a: String): Node! 15 | listVariable(as: [String]): Node! 16 | multipleVariables(a: String, b: String): Node! 17 | primitiveResponse(a: String): String! 18 | optionalPrimitiveResponse(a: String): String 19 | listResponse(a: String): [String!]! 20 | } 21 | 22 | input Input { 23 | a: String! 24 | } 25 | 26 | input Nested { 27 | input: Input! 28 | } 29 | 30 | type Node { 31 | id: ID! 32 | } 33 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/subscription/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | subscription TestNoVariablesSubscription { 2 | noVariables { 3 | id 4 | } 5 | } 6 | 7 | subscription TestObjectVariableSubscription($input: Input!) { 8 | objectVariable(input: $input) { 9 | id 10 | } 11 | } 12 | 13 | subscription TestOptionalObjectVariableSubscription($input: Input) { 14 | objectVariable(input: $input) { 15 | id 16 | } 17 | } 18 | 19 | subscription TestNestedObjectVariableSubscription($nested: Nested) { 20 | nestedObjectVariable(nested: $nested) { 21 | id 22 | } 23 | } 24 | 25 | subscription TestPrimitiveVariableSubscription($a: String!) { 26 | primitiveVariable(a: $a) { 27 | id 28 | } 29 | } 30 | 31 | subscription TestOptionalPrimitiveVariableSubscription($a: String) { 32 | primitiveVariable(a: $a) { 33 | id 34 | } 35 | } 36 | 37 | subscription TestListVariableSubscription($as: [String!]!) { 38 | listVariable(as: $as) { 39 | id 40 | } 41 | } 42 | 43 | subscription TestOptionalListVariableSubscription($as: [String!]) { 44 | listVariable(as: $as) { 45 | id 46 | } 47 | } 48 | 49 | subscription TestMultipleVariablesSubscription($a: String!, $b: String!) { 50 | multipleVariables(a: $a, b: $b) { 51 | id 52 | } 53 | } 54 | 55 | subscription TestPrimitiveResponseSubscription($a: String!) { 56 | primitiveResponse(a: $a) 57 | } 58 | 59 | subscription TestOptionalPrimitiveResponseSubscription($a: String!) { 60 | optionalPrimitiveResponse(a: $a) 61 | } 62 | 63 | subscription TestListResponseSubscription($a: String!) { 64 | listResponse(a: $a) 65 | } 66 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/type-mapping/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "graphql" / "Schema.graphqls" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | // Avoid picking up the expected files in the unmanagedSources. 26 | unmanagedSources / excludeFilter ~= (_ || "*.scala") 27 | 28 | Compile / relayConvertTypeMappings += "Foo" -> "Bar" 29 | 30 | logLevel := Level.Debug 31 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/type-mapping/expected/ClientTypeNestedInput.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | 6 | /* 7 | input ClientTypeNestedInput { 8 | nested: Foo! 9 | } 10 | */ 11 | 12 | trait ClientTypeNestedInput extends js.Object { 13 | val nested: Bar 14 | } 15 | 16 | object ClientTypeNestedInput { 17 | def apply( 18 | nested: Bar 19 | ): ClientTypeNestedInput = 20 | js.Dynamic.literal( 21 | nested = nested 22 | ).asInstanceOf[ClientTypeNestedInput] 23 | } 24 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/type-mapping/expected/Test_fragment.scala: -------------------------------------------------------------------------------- 1 | package relay.generated 2 | 3 | import _root_.scala.scalajs.js 4 | import _root_.scala.scalajs.js.| 5 | import _root_.scala.scalajs.js.annotation.JSImport 6 | 7 | /* 8 | fragment Test_fragment on ClientTypeOutput { 9 | id 10 | number 11 | required 12 | optional 13 | requiredListRequiredElements 14 | requiredListOptionalElements 15 | optionalListRequiredElements 16 | optionalListOptionalElements 17 | object { 18 | required 19 | } 20 | interface { 21 | required 22 | } 23 | } 24 | */ 25 | 26 | @js.native 27 | trait Test_fragment extends js.Object { 28 | val id: String | Null 29 | val number: Double | Null 30 | val required: Bar 31 | val optional: Bar | Null 32 | val requiredListRequiredElements: js.Array[Bar] 33 | val requiredListOptionalElements: js.Array[Bar | Null] 34 | val optionalListRequiredElements: js.Array[Bar] | Null 35 | val optionalListOptionalElements: js.Array[Bar | Null] | Null 36 | val `object`: Test_fragment.Object 37 | val interface: Test_fragment.Interface 38 | } 39 | 40 | object Test_fragment extends _root_.com.goodcover.relay.FragmentTaggedNode[Test_fragment] { 41 | type Ctor[T] = T 42 | 43 | @js.native 44 | trait Object extends js.Object { 45 | val required: Bar 46 | } 47 | 48 | @js.native 49 | trait Interface extends js.Object { 50 | val required: Bar 51 | } 52 | 53 | type Query = _root_.com.goodcover.relay.ReaderFragment[Ctor, Out] 54 | 55 | @js.native 56 | @JSImport("__generated__/Test_fragment.graphql", JSImport.Default) 57 | private object node extends js.Object 58 | 59 | lazy val query: Query = node.asInstanceOf[Query] 60 | 61 | lazy val sourceHash: String = node.asInstanceOf[js.Dynamic].hash.asInstanceOf[String] 62 | } 63 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/type-mapping/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/type-mapping/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/type-mapping/src/main/resources/graphql/Schema.graphqls: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | } 4 | 5 | scalar Foo 6 | 7 | type Query { 8 | clientType(input: ClientTypeInput): ClientTypeOutput 9 | primitiveVariable(a: Foo): ClientTypeOutput 10 | } 11 | 12 | input ClientTypeInput { 13 | id: ID 14 | number: Float 15 | required: Foo! 16 | optional: Foo 17 | requiredListRequiredElements: [Foo!]! 18 | requiredListOptionalElements: [Foo]! 19 | optionalListRequiredElements: [Foo!] 20 | optionalListOptionalElements: [Foo] 21 | nested: ClientTypeNestedInput! 22 | } 23 | 24 | input ClientTypeNestedInput { 25 | nested: Foo! 26 | } 27 | 28 | type ClientTypeOutput { 29 | id: ID 30 | number: Float 31 | required: Foo! 32 | optional: Foo 33 | requiredListRequiredElements: [Foo!]! 34 | requiredListOptionalElements: [Foo]! 35 | optionalListRequiredElements: [Foo!] 36 | optionalListOptionalElements: [Foo] 37 | object: ClientTypeNestedObject! 38 | interface: ClientTypeNestedInterface! 39 | } 40 | 41 | type ClientTypeNestedObject { 42 | required: Foo! 43 | } 44 | 45 | interface ClientTypeNestedInterface { 46 | required: Foo! 47 | } 48 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/type-mapping/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | query TestQuery($input: ClientTypeInput!) { 2 | clientType(input: $input) { 3 | id 4 | number 5 | required 6 | optional 7 | requiredListRequiredElements 8 | requiredListOptionalElements 9 | optionalListRequiredElements 10 | optionalListOptionalElements 11 | object { 12 | required 13 | } 14 | interface { 15 | required 16 | } 17 | } 18 | } 19 | 20 | fragment Test_fragment on ClientTypeOutput { 21 | id 22 | number 23 | required 24 | optional 25 | requiredListRequiredElements 26 | requiredListOptionalElements 27 | optionalListRequiredElements 28 | optionalListOptionalElements 29 | object { 30 | required 31 | } 32 | interface { 33 | required 34 | } 35 | } 36 | 37 | query TestPrimitiveVariableQuery($a: String!) { 38 | primitiveVariable(a: $a) { 39 | id 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-convert/type-mapping/test: -------------------------------------------------------------------------------- 1 | > relayConvert 2 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/TestQuery.scala expected/TestQuery.scala 3 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/ClientTypeInput.scala expected/ClientTypeInput.scala 4 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/ClientTypeNestedInput.scala expected/ClientTypeNestedInput.scala 5 | $ must-mirror target/scala-2.13/src_managed/main/relay/generated/Test_fragment.scala expected/Test_fragment.scala 6 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/basic/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | libraryDependencies += "com.goodcover.relay" %%% "scala-relay-macros" % com.goodcover.relay.BuildInfo.version 5 | 6 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 7 | 8 | scalacOptions += "-Ymacro-annotations" 9 | 10 | scalaVersion := "2.13.16" 11 | 12 | useYarn := true 13 | 14 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 15 | 16 | relaySchema := (Compile / resourceDirectory).value / "testschema.graphql" 17 | 18 | relayDebug := true 19 | 20 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 21 | 22 | Compile / relayDisplayOnlyOnFailure := true 23 | 24 | webpack / version := "5.75.0" 25 | 26 | logLevel := Level.Debug 27 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/basic/expected.template.graphql: -------------------------------------------------------------------------------- 1 | # Extracted from ${PWD}/src/main/scala/example/Test.scala 2 | # This is rad! 3 | query TestQuery { 4 | defaultSettings { 5 | notificationSounds 6 | cache_id 7 | } 8 | } 9 | 10 | # Extracted from ${PWD}/src/main/scala/example/Test.scala 11 | fragment Test_foo on Foo { 12 | bar { 13 | baz 14 | } 15 | } 16 | 17 | # Extracted from ${PWD}/src/main/scala/example/Test.scala 18 | fragment Test_foo2 on Foo { 19 | id 20 | } 21 | 22 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/basic/make-expected.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euxo pipefail 4 | 5 | # Don't use inline because macOS has different options. 6 | sed "s|\${PWD}|$(readlink -f "$(pwd)")|g" expected.template.graphql > expected.graphql 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/basic/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/basic/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/basic/src/main/scala/example/Test.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | import com.goodcover.relay.macros 4 | 5 | @graphql(""" 6 | # This is rad! 7 | query TestQuery { 8 | defaultSettings { 9 | notificationSounds 10 | cache_id 11 | } 12 | } 13 | """) 14 | object Test { 15 | 16 | graphqlGen(""" 17 | 18 | fragment Test_foo on Foo { 19 | bar { 20 | baz 21 | } 22 | } 23 | 24 | 25 | """) 26 | 27 | macros.graphqlGen(""" 28 | fragment Test_foo2 on Foo { 29 | id 30 | } 31 | """) 32 | } 33 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/basic/test: -------------------------------------------------------------------------------- 1 | $ exec ./make-expected.sh 2 | 3 | # This should extract as expected. 4 | > relayExtract 5 | $ must-mirror target/scala-2.13/resource_managed/main/relay/graphql/Test.graphql expected.graphql 6 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/cache/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "testschema.graphql" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | logLevel := Level.Debug 26 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/cache/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/cache/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/cache/replace-version.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euxo pipefail 4 | 5 | if [[ "$OSTYPE" == "darwin"* ]]; then 6 | sed -E -i '' 's/"version":[0-9]+/"version":0/g' target/streams/compile/relayExtract/_global/streams/relay/extract/last 7 | else 8 | sed -E -i 's/"version":[0-9]+/"version":0/g' target/streams/compile/relayExtract/_global/streams/relay/extract/last 9 | fi 10 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/cache/src/main/scala/example/NoQuery.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | // Ensures that the unmodified file detection works when there are sources with no output. 4 | object NoQuery { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/cache/src/main/scala/example/Test.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | @graphql(""" 4 | query TestQuery { 5 | defaultSettings { 6 | notificationSounds 7 | cache_id 8 | } 9 | } 10 | """) 11 | object Test { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/cache/src/main/scala/example/Test2.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | @graphql(""" 4 | query TestQuery2 { 5 | defaultSettings { 6 | notificationSounds 7 | cache_id 8 | } 9 | } 10 | """) 11 | object Test2 { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/cache/src/main/scala/example/Test2.scala.bak: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | @graphql(""" 4 | query TestQuery2 { 5 | defaultSettings { 6 | notificationSounds 7 | } 8 | } 9 | """) 10 | object Test2 { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/collision/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "testschema.graphql" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | logLevel := Level.Debug 26 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/collision/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/collision/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/collision/src/main/scala/example/Test.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | @graphql(""" 4 | query TestQuery { 5 | defaultSettings { 6 | notificationSounds 7 | cache_id 8 | } 9 | } 10 | """) 11 | object Test { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/collision/src/main/scala/example2/Test.bak: -------------------------------------------------------------------------------- 1 | package example2 2 | 3 | @graphql(""" 4 | query Test3Query { 5 | defaultSettings { 6 | notificationSounds 7 | cache_id 8 | } 9 | } 10 | """) 11 | object Test3 { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-extract/collision/src/main/scala/example2/Test.scala: -------------------------------------------------------------------------------- 1 | package example2 2 | 3 | @graphql(""" 4 | query Test2Query { 5 | defaultSettings { 6 | notificationSounds 7 | cache_id 8 | } 9 | } 10 | """) 11 | object Test2 { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/argument-definitions/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "testschema.graphql" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | logLevel := Level.Debug 26 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/argument-definitions/expected.js: -------------------------------------------------------------------------------- 1 | graphql` 2 | fragment Test_root on Root @argumentDefinitions(searchTerm: {type: "String"}, before: {type: "String"}, last: {type: "Int"}, after: {type: "String"}, first: {type: "Int"}) { 3 | viewer { 4 | things(searchTerm: $searchTerm, before: $before, last: $last, after: $after, first: $first) { 5 | edges { 6 | node { 7 | text 8 | } 9 | } 10 | pageInfo { 11 | startCursor 12 | hasNextPage 13 | endCursor 14 | hasPreviousPage 15 | } 16 | } 17 | } 18 | }` 19 | 20 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/argument-definitions/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/argument-definitions/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/argument-definitions/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | fragment Test_root on Root @argumentDefinitions( 2 | searchTerm: { type: "String" }, 3 | after: { type: "String" }, 4 | before: { type: "String" }, 5 | first: { type: "Int" }, 6 | last: { type: "Int" }, 7 | ){ 8 | viewer { 9 | things(after: $after, first: $first, last: $last, before: $before, searchTerm: $searchTerm) { 10 | edges { 11 | node { 12 | text 13 | } 14 | } 15 | pageInfo { 16 | startCursor 17 | hasNextPage 18 | endCursor 19 | hasPreviousPage 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/argument-definitions/test: -------------------------------------------------------------------------------- 1 | # This should wrap as expected. 2 | > relayWrap 3 | $ must-mirror target/scala-2.13/resource_managed/main/relay/js/Test.js expected.js 4 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/basic/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "testschema.graphql" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | logLevel := Level.Debug 26 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/basic/expected.js: -------------------------------------------------------------------------------- 1 | graphql` 2 | query TestQuery { 3 | defaultSettings { 4 | notificationSounds 5 | cache_id 6 | } 7 | }` 8 | 9 | graphql` 10 | fragment Test_foo on Foo { 11 | bar { 12 | baz 13 | } 14 | }` 15 | 16 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/basic/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/basic/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/basic/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | # Extracted from src/main/scala/example/Test.scala 2 | # This is rad! 3 | query TestQuery { 4 | defaultSettings { 5 | notificationSounds 6 | cache_id 7 | } 8 | } 9 | 10 | # Extracted from src/main/scala/example/Test.scala 11 | fragment Test_foo on Foo { 12 | bar { 13 | baz 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/basic/test: -------------------------------------------------------------------------------- 1 | # This should wrap as expected. 2 | > relayWrap 3 | $ must-mirror target/scala-2.13/resource_managed/main/relay/js/Test.js expected.js 4 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/cache/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "testschema.graphql" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | logLevel := Level.Debug 26 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/cache/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/cache/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/cache/replace-version.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euxo pipefail 4 | 5 | if [[ "$OSTYPE" == "darwin"* ]]; then 6 | sed -E -i '' 's/"version":[0-9]+/"version":0/g' target/streams/compile/relayWrap/_global/streams/relay/wrap/last 7 | else 8 | sed -E -i 's/"version":[0-9]+/"version":0/g' target/streams/compile/relayWrap/_global/streams/relay/wrap/last 9 | fi 10 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/cache/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | query TestQuery { 2 | defaultSettings { 3 | notificationSounds 4 | cache_id 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/cache/src/main/resources/graphql/Test2.graphql: -------------------------------------------------------------------------------- 1 | query TestQuery2 { 2 | defaultSettings { 3 | notificationSounds 4 | cache_id 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/cache/src/main/resources/graphql/Test2.graphql.bak: -------------------------------------------------------------------------------- 1 | query TestQuery2 { 2 | defaultSettings { 3 | notificationSounds 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/collision/build.sbt: -------------------------------------------------------------------------------- 1 | name := "basic" 2 | 3 | libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" 4 | 5 | enablePlugins(ScalaRelayPlugin, ScalaJSBundlerPlugin) 6 | 7 | scalacOptions += "-Ymacro-annotations" 8 | 9 | scalaVersion := "2.13.16" 10 | 11 | useYarn := true 12 | 13 | relayCompilerCommand := s"node ${(Compile / npmInstallDependencies).value}/node_modules/.bin/relay-compiler" 14 | 15 | relaySchema := (Compile / resourceDirectory).value / "testschema.graphql" 16 | 17 | relayDebug := true 18 | 19 | Compile / npmDevDependencies ++= (Compile / relayDependencies).value 20 | 21 | Compile / relayDisplayOnlyOnFailure := true 22 | 23 | webpack / version := "5.75.0" 24 | 25 | logLevel := Level.Debug 26 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/collision/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.1 2 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/collision/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin( 2 | "com.goodcover.relay" % "sbt-scala-relay" % sys.props 3 | .getOrElse("plugin.version", sys.error("'plugin.version' environment variable is not set")) 4 | ) 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") 7 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/collision/src/main/resources/graphql/Test.graphql: -------------------------------------------------------------------------------- 1 | # Extracted from src/main/scala/example/Test.scala 2 | # This is rad! 3 | query TestQuery { 4 | defaultSettings { 5 | notificationSounds 6 | cache_id 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/collision/src/main/scala/example/Test.bak: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | @graphql(""" 4 | query Test3Query { 5 | defaultSettings { 6 | notificationSounds 7 | cache_id 8 | } 9 | } 10 | """) 11 | object Test 12 | -------------------------------------------------------------------------------- /sbt-scala-relay/src/sbt-test/relay-wrap/collision/src/main/scala/example/Test.scala: -------------------------------------------------------------------------------- 1 | package example 2 | 3 | @graphql(""" 4 | query Test2Query { 5 | defaultSettings { 6 | notificationSounds 7 | cache_id 8 | } 9 | } 10 | """) 11 | object Test 12 | -------------------------------------------------------------------------------- /scala-relay-core/src/main/scala-2/com/goodcover/relay/UnionImplicits.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay 2 | 3 | import scala.scalajs.js 4 | import scala.scalajs.js.| 5 | import scala.scalajs.js.|.Evidence 6 | 7 | trait UnionImplicits { 8 | 9 | @inline 10 | private val baseEv: Evidence[js.Any, js.Any] = 11 | Evidence.base[js.Any] 12 | 13 | @inline 14 | implicit val unitEv: Evidence[Unit, js.Any] = 15 | baseEv.asInstanceOf[Evidence[Unit, js.Any]] 16 | 17 | @inline 18 | implicit val booleanEv: Evidence[Boolean, js.Any] = 19 | baseEv.asInstanceOf[Evidence[Boolean, js.Any]] 20 | 21 | @inline 22 | implicit val byteEv: Evidence[Byte, js.Any] = 23 | baseEv.asInstanceOf[Evidence[Byte, js.Any]] 24 | 25 | @inline 26 | implicit val shortEv: Evidence[Short, js.Any] = 27 | baseEv.asInstanceOf[Evidence[Short, js.Any]] 28 | 29 | @inline 30 | implicit val intEv: Evidence[Int, js.Any] = 31 | baseEv.asInstanceOf[Evidence[Int, js.Any]] 32 | 33 | @inline 34 | implicit val floatEv: Evidence[Float, js.Any] = 35 | baseEv.asInstanceOf[Evidence[Float, js.Any]] 36 | 37 | @inline 38 | implicit val doubleEv: Evidence[Double, js.Any] = 39 | baseEv.asInstanceOf[Evidence[Double, js.Any]] 40 | 41 | @inline 42 | implicit val stringEv: Evidence[String, js.Any] = 43 | baseEv.asInstanceOf[Evidence[String, js.Any]] 44 | 45 | implicit def mergeUnion[A, B, C](ab: A | B)(implicit evA: Evidence[A, C], evB: Evidence[B, C]): C = 46 | ab.asInstanceOf[C] 47 | 48 | } 49 | 50 | object UnionImplicits extends UnionImplicits 51 | -------------------------------------------------------------------------------- /scala-relay-core/src/main/scala-2/relay/generated/package.scala: -------------------------------------------------------------------------------- 1 | package relay 2 | 3 | import com.goodcover.relay.UnionImplicits 4 | 5 | package object generated extends UnionImplicits 6 | -------------------------------------------------------------------------------- /scala-relay-core/src/main/scala/com/goodcover/relay/FragmentRef.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait FragmentRef[+T] extends js.Object 7 | -------------------------------------------------------------------------------- /scala-relay-core/src/main/scala/com/goodcover/relay/Introspectable.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay 2 | 3 | import scala.scalajs.js 4 | 5 | @js.native 6 | trait Introspectable[A] extends js.Object { 7 | val __typename: Introspectable.TypeName[A] 8 | } 9 | 10 | object Introspectable { 11 | 12 | @js.native 13 | trait TypeName[A] extends js.Any 14 | 15 | def as[A <: Introspectable[A], B <: A](f: A, typeName: TypeName[B]): Option[B] = { 16 | if (f == null) None 17 | else if (f.__typename == typeName) Some(f.asInstanceOf[B]) 18 | else None 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /scala-relay-core/src/main/scala/com/goodcover/relay/graphql.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay 2 | 3 | import scala.annotation.StaticAnnotation 4 | 5 | class graphql(s: String) extends StaticAnnotation 6 | -------------------------------------------------------------------------------- /scala-relay-core/src/main/scala/com/goodcover/relay/package.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover 2 | 3 | package object relay { 4 | 5 | type ReaderFragment[F[_], O] = TaggedNodeQuery[F, O, Block] 6 | 7 | type ReaderInlineDataFragment[F[_], O] = TaggedNodeQuery[F, O, Inline] 8 | } 9 | -------------------------------------------------------------------------------- /scala-relay-ijext/src/main/scala/com/goodcover/relay/GraphQLGenInjector.scala: -------------------------------------------------------------------------------- 1 | package com.goodcover.relay 2 | 3 | import org.jetbrains.plugins.scala.lang.macros.evaluator.{MacroContext, MacroImpl, ScalaMacroTypeable} 4 | import org.jetbrains.plugins.scala.lang.psi.api.statements.ScFunction 5 | import org.jetbrains.plugins.scala.lang.psi.impl.ScalaPsiElementFactory 6 | import org.jetbrains.plugins.scala.lang.psi.types.ScType 7 | 8 | class GraphQLGenInjector extends ScalaMacroTypeable { 9 | override def checkMacro(macros: ScFunction, context: MacroContext): Option[ScType] = { 10 | 11 | val reg = """graphqlGen\([\s]*\"\"\"([\s\S]*?)\"\"\"\)""".r 12 | 13 | reg.findFirstMatchIn(context.place.getText) match { 14 | case Some(value) => 15 | val reg = raw"(fragment|mutation|subscription|query)[\s]+([\w]+)".r 16 | val opAndName = for (m <- reg.findFirstMatchIn(value.group(1))) yield (m.group(1), m.group(2)) 17 | opAndName match { 18 | case Some((_, name)) => 19 | val tpe = s"_root_.relay.generated.${name}.type" 20 | ScalaPsiElementFactory.createTypeFromText(tpe, context.place, null) 21 | case None => None 22 | } 23 | case None => None 24 | } 25 | 26 | } 27 | 28 | override val boundMacro: Seq[MacroImpl] = Seq(MacroImpl("graphqlGen", "com.goodcover.relay.macros")) 29 | } 30 | -------------------------------------------------------------------------------- /scripts/import-gpg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -xe 4 | 5 | echo $PGP_PUBLIC 6 | echo "$PGP_SECRET" | gpg --import -------------------------------------------------------------------------------- /version.sbt: -------------------------------------------------------------------------------- 1 | ThisBuild / version := "0.45.2-SNAPSHOT" 2 | --------------------------------------------------------------------------------