Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend backend communication? #1385

Closed
strasdat opened this issue Jul 7, 2020 · 4 comments
Closed

Frontend backend communication? #1385

strasdat opened this issue Jul 7, 2020 · 4 comments
Labels

Comments

@strasdat
Copy link

strasdat commented Jul 7, 2020

Question

What are the best alternatives to communicate from front-end rust/yew to back-end rust? Somewhere I read that some folks use GraphQL. But I'm wondering whether there is a more direct, more rusty approach...

Am I just unaware of corresponding technology, or do we have to invent something?

@teymour-aldridge
Copy link
Contributor

teymour-aldridge commented Jul 7, 2020

Sascha Grunert has published a project building a web application with Yew which uses the Cap'n Proto protocol for data transfer which is really neat.

Yew also provides a Fetch service and WebSocket service which you could send GraphQL queries using (or use to connect to a RESTful API).

@jstarry
Copy link
Member

jstarry commented Jul 19, 2020

Yeah, I think it's on you to pick your transport protocol (http or ws), request protocol (jsonrpc, graphql, etc), and encoding (json, binary, capn proto). Yew has wrappers around fetch and WebSocket which could be used to build a request protocol but they aren't needed. Ideally the rust / wasm ecosystem evolves such that graphql, jsonrpc, etc client libraries support wasm targets by building on web-sys or other abstractions over the browser APIs.

For example, for work we've been exploring the use of https://github.com/google/tarpc which is pretty close to being able to build to wasm and makes it easy to provide your own transport (in our case websockets).

So, you may have to fork an existing client to get it working with wasm, I would be surprised if you had to write a totally new graphql client, but I'm not familiar with those rust projects.

@teymour-aldridge
Copy link
Contributor

I'm working on a GraphQL client (still very early on in the process, but it looks like it might show some promise), which is something like a Relay or Apollo GraphQL clone. You might be interested in it.

@kellpossible
Copy link
Contributor

Tarpc looks excellent, can't remember if it has wasm support yet.
I'm currently using websockets + serde + serde_json for a work project. Might swap out serde_json for something else later if it becomes a bottleneck, but it does make testing/debugging easy.
For an rpc framework, jsonrpc is pretty simple and could be implemented yourself if none of the existing rust libraries fit your needs.

@yewstack yewstack locked and limited conversation to collaborators Nov 21, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

5 participants