sbt-graphql icon indicating copy to clipboard operation
sbt-graphql copied to clipboard

Support query code gen for scala.js client

Open ngbinh opened this issue 7 years ago • 6 comments

It would be great if we can do so. At the moment, I am not sure how to achieve that.

ngbinh avatar May 19 '18 10:05 ngbinh

Thanks for your feature request 🤗

What do you exactly mean? The generated sources should work for the JVM and scala.js. A shared project could contain all queries, which can be reused on both sides.

The Apollo style generation generates self contained query/mutation objects, so you don't have to worry about any "how to get the query from source" issues 😎

muuki88 avatar May 20 '18 08:05 muuki88

Thanks for the quick reply,

For Apollo style, the generated code contains import sangria.macros._. I don't think sangria has published artifact for scala.js. https://mvnrepository.com/artifact/org.sangria-graphql/sangria

For Sangria code gen style, I believe I had some trouble with scalar type when the generated code doesn't seem to include the type so it could not be compiled.

ngbinh avatar May 20 '18 11:05 ngbinh

For Apollo style, the generated code contains import sangria.macros._. I don't think sangria has published artifact for scala.js

Ah, true. We only need that for the document parsing. If we can make this configurable to only use a string, the it would work.

Maybe we can tweak the Apollo style in this direction.

muuki88 avatar May 20 '18 13:05 muuki88

For Sangria code gen with scalar type, I will try to use ScalarAlias to see if it work and report back here.

ngbinh avatar May 20 '18 13:05 ngbinh

So 'ScalarAliasworks but notScalarType`.

ngbinh avatar May 22 '18 02:05 ngbinh

Thanks for the clarification. The recent #26 is about the missing support for ScalarType

jonas avatar Jun 03 '18 01:06 jonas