facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.41k stars 1.83k forks source link

Relay Rust compiler for other clients #4420

Open satvikpendem opened 1 year ago

satvikpendem commented 1 year ago

I'm looking to create a Relay-compatible client for a non-React framework, and as part of that, I thought that instead reinventing the wheel, I could leverage the Relay compiler in Rust that you already have such that it could detect the fragments in the new non-React syntax and then compile them together just as it would for the React client.

Is this feasible, or is the compiler strongly bound to the React syntax?

sibelius commented 1 year ago

It just look for graphql tags

satvikpendem commented 1 year ago

Thanks, I'd still have to generate hooks for this other client, so would that be a big change? Where would I find the code for that part?

sibelius commented 1 year ago

inside relay compiler

edvinerikson commented 1 year ago

If you're just looking to build support for another framework/runtime. I would suggest looking at relay-runtime instead. The react specific parts is inside the react-relay package so in theory you would only replace that package with something for your needs and still leverage the other parts such as the compiler and runtime.

satvikpendem commented 1 year ago

Awesome, I'll take a look at that. So the relay-runtime package stays the same but it links to react-relay and I'd just have to change where relay-runtime links to, I assume?

edvinerikson commented 1 year ago

react-relay references relay-runtime. So by just skipping installing react-relay you essentially have relay without react. So at that point you just need to build new APIs that work with the framework you want. Imagine a "<framework>-relay" package.

satvikpendem commented 1 year ago

Ah thanks so much!