apollo-scalajs
apollo-scalajs copied to clipboard
Support pre-processing of GraphQL queries
Thank you for this awesome integration with scala.js … im currently experimenting with a basic template that produces acceptable bundle sizes and figured that this integration is missing a great opportunity to save bytes by pre-processing the graphql queries during build time and removing the runtime dependency on graphql-tag
!
For a reference you can checkout https://github.com/gajus/babel-plugin-graphql-tag which does not work with this library atm … i can only guess because it only removes imports / gql
template tags which are not used by this library.
Scala.js does not know about JS template tags, so using gql
just results in a call being emitted to the gql
function. Therefore it won't be possible to use the Babel plugin to handle parsing at build time.
I'll keep this open since it could theoretically be possible to reimplement all of graphql-tag
in Scala and then run that with a macro. In the apps I know of using Apollo Scala.js though, graphql-tag
ends up taking relatively little space in the overall bundle.
Thanks for the fast respone @shadaj!
Regarding gql
: Yeah i thought so - probably the Scala.js community should also think about how to incorporate Javascript improvements like template literal (+tags) since these are powerful features that are becoming mainstream and thus Scala.js is getting less and less compatible with the Js world if not keeping up (hence, providing more than just ES5 target)
But of course this is not the right repo to discuss that 😉 im not sure if it would be the best approach to re-implement (very specific) existing js libraries as we would lose the power of the existing community.
Regarding code size: yes, my general problem with GraphQL right now is that it massively bloats my frontend code size … altough im not yet sure if i might do something wrong, since a very basic example outputs already more than 700kb (not gzipped) of which ~300kb is just GraphQL stuff.