Photo by Bill Oxford on Unsplash
Setting up a GraphQL server with Rust, Juniper, Diesel, and Actix; learning about Rust's web frameworks and power...
For further actions, you may consider blocking this person and/or reporting abuse
This kind of articles are the ones that incites you to install a new tool and try some things out. 👌
Nice article!
In the Exposing the Schema section, just prior to running cargo build and navigating to localhost:8080/graphiql, I couldn't get main.rs to compile without changing
to
Am I missing something?
Ah thank you, you found an error in the snippet. I just changed it but you're correct, since the module is called graphql_schema we must refer to it like that.
Originally I had it called 'schema.rs' until I added the diesel integration (whose migrations overwrite whatever you have in schema.rs)
Another issue (you may be able to glean that I've been slowly working through the article over the past few days):
You don't seem to instruct adding the
extern crate diesel;
andmod schema;
lines to main.rs. That prevented me from compiling after setting up diesel (immediately prior to adding the mutations).Thank you for being so thorough! I added another snippet at that point adding the imports. Hopefully that is the end of the errata - transpiling code from a project to an article in a digestible way comes with some struggles :D
Thanks, great article. Seems like soon they will also support subscriptions. Then I can finally 'use' it and compare to my Clojure implementation. Then one is 'stuck' at about 300 subscriptions/second hope for Rust to do better. Also there is github.com/tsegismont/graphql-serv..., maybe you can add a rust version?
Yes - hopefully subscriptions will land soon, I saw your comment on that issue: github.com/graphql-rust/juniper/is.... Ah that's a pretty neat project, where is your Clojure implementation? I'll consider it, I too am interested in how it stacks up.
Haven't had the time yet. Preparing to speak at GraphQL Summit, polishing presentation and maybe make some improvements to the demo. I have github.com/openweb-nl/open-bank-mark but that's testing the Kafka backend more. Next iteration of that will focus on the GraphQL endpoint (and may in time have a rust variant for it).
Great article! I have a repo that also uses these technologies together. Although it uses Diesel connection pool (R2D2) to connect to postgreSQL and passes the connection through to the Juniper GraphQL Context, to be accessed from the QueryRoot and MutationRoot.
i.e:
#[juniper::object(Context = Context,)]
You probably already know how to hook all that up, but it took me ages to figure out. Just thought you might be interested. github.com/fattenap/actix-web-juni...
Anyway, thanks for the article, it really helped.
Got sad news, actix-web is dead. I hope the maintainer will not abandon it. Damn. Ian, will you update the article in the future using an alternative non-blocking framework? warp/gotham/tide/rocket any framework that you feel it can be used for a small production project? Thanks!
I heard that in this post words.steveklabnik.com/a-sad-day-f.... I may create a new article and link to it from here. That sucks indeed, the library is a joy to use so I hope this won't be the end.
Update: actix-web is alive. Whew! Hope it won't happen again.
Source: github.com/actix/actix-web/issues/...
That is great news! :D
Great tutorial. I am getting stuck on the diesel migrations. I used various
DATABASE_URL
and even looked at the diesel getting started guide where they said to usepostgres://username:password@localhost/diesel_demo
and everyone I rundiesel setup
I getand if I try to run
diesel migration run
I getErr value: ConnectionError(BadConnection("fe_sendauth: no password supplied\n"))
Do you know why this could be ? I installed
PostgreSQ
L withbrew and the
PGAdmin` seems to be working fine.Dope man! Well made 👏 👏 👏
I ran across an issue with Actix with how the Response was structured inside of the web::block() moving the Response and Error construction outside resolved this for me. I found an issue related as well in their GH (github.com/actix/actix-web/issues/857)
Code Snippet of Changes
Hello, thank you for the article and the inspiration!
I did a little boilerplate project with GraphQL and JWT Authentication, Feel free to comment :)
github.com/clifinger/canduma
Nice! I like what you did there, authentication is a pretty serious part of writing non-abusable and secure APIs
great!
Thanks!!
Brilliant article. Thanks.