To have proper interop with JS, there is a need for binding to tagged template literals. I especially run into this with graphql-ppx
because most GraphQL libraries use tagged template literals to represent GraphQL operations and fragments. We found a hacky way to bind to them that involves require
and %raw
but it’s not ideal.
I think there could be quite nice way to bind to them. The below could be the function signature:
let graphql: (array(string), @variadic array('a)) => 'b
And the following syntax:
graphql`
query {
...MyFragment
}
${myFragment}
`
would be the same in ReScript and JS. It can even be supported in non-es6 by just calling the function.
The “only” language feature we need is the @variadic
annotation in the last argument. Not sure if that is feasible, and it might be only implementable with an external
(which would actually be quite ok, because normally we would only use template literals to bind to external libraries).
Thoughts about this?