Git Product home page Git Product logo

graphql-app-example's Introduction

Rust GraphQL example app

This project provides a complete example how to setup a Rust GraphQL web server using the following libraries:

Running the app

Create the (postgres) database and run migrations by running bin/setup. We create both a development and test database.

Then compile and run the app

$ cargo run

Then go to http://localhost:8000/graphiql.

Or run the tests with

$ cargo test

Note

This is by no means meant to demonstrate the best practices for making a web app with Rocket. Several important topics such as authentication and error handling is not addressed. It is meant to be used as a template for starting new apps.

graphql-app-example's People

Contributors

dependabot-preview[bot] avatar davidpdrsn avatar

Stargazers

Nico Zamora avatar Hoang Lo avatar  avatar  avatar David M. Golembiowski avatar Radu Crisan avatar Nico avatar Tristan Jeroen avatar  avatar Niels Kristian Skovmand avatar Fernando Mumbach avatar wood avatar Andrejs Agejevs avatar Saadi Save avatar Michael Cheng avatar Zach Mead avatar Tejas Agarwal avatar Marcio Castilho avatar Christoph avatar Brad Pillow avatar Rashad Aliyev avatar Pep avatar Hongyi Lyu avatar kanchi avatar  avatar Kyle Lacy avatar Moritz Hedtke avatar Paul avatar Shashank Pachava avatar ik5 avatar GAURAV avatar yuchou avatar Lucas Holder avatar Lukas Steiner avatar ryan avatar  avatar Vlady Veselinov avatar Daniel Hendrie avatar Paolo Barbolini avatar Tadej Stanic avatar Matthias Riße avatar Flux Xu avatar Nicolas Marshall avatar Eric Semeniuc avatar turkeyzawa avatar Satoru Sukawa avatar Alban avatar Ahmed Refaat avatar Sven avatar Youssef Habri avatar Mohammed Abubakar avatar Royce Aquino avatar Jason avatar dreamer avatar Lance avatar Alexis H. Munsayac avatar Anthony Mittaz avatar Jack Hollis-London avatar Uther Pally avatar Jiayu Ye avatar Nainesh Gohil avatar  avatar  avatar  avatar Allan Alexandre avatar Xargin avatar Clement Rey avatar Gavin Ray avatar andrisak avatar Robby avatar Nate Strandberg avatar Jang avatar Gabor Dolla avatar Matthew McMillan avatar Cheng JIANG avatar Blaž Hrastnik avatar Ibrahim Alhamad avatar Tim Kendall avatar Sangguk Lee avatar  avatar Cormac Relf avatar Jason Mandel avatar Rust avatar Eric Dattore avatar Chris avatar Mick Dekkers avatar Rafał Muszyński avatar Atul Bhosale avatar gc-o avatar Sonny Scroggin avatar danielsdesk avatar Daniel G. avatar Christian Legnitto avatar Sacha Arbonel avatar Márton Danóczy avatar Dan Bruder avatar Frank Panetta avatar Thomas Forgione avatar  avatar Mitch Skinner avatar

Watchers

 avatar James Cloos avatar sordfish avatar Mick Dekkers avatar  avatar yuchou avatar

graphql-app-example's Issues

Unable to run setup script completely

Hi! I'm just starting out with Rust so this is all very new to me so I wanted to say thanks for creating this example repo, it's been helpful 😄

I am hitting an error when running bash bin/setup though - have you seen or know about this error?

Compiling rocket_http v0.4.5
error: proc macro panicked
   --> /home/onx2/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_http-0.4.5/src/parse/uri/parser.rs:119:34
    |
119 |             let path_and_query = pear_try!(path_and_query(is_pchar));
    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: message: called `Option::unwrap()` on a `None` value
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

error: could not compile `rocket_http`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
^C  Building [====================================================>  ] 195/201: diesel 

As an aside, I had to change the database url in the setup script to include the user and password, so something like this:

echo DATABASE_URL=postgres://username:password@localhost/graphql-app-example >> .env

Dependabot can't resolve your Rust dependency files

Dependabot can't resolve your Rust dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
info: latest update on 2019-07-22, rust version 1.38.0-nightly (273f42b59 2019-07-21)
info: downloading component 'rustc'
info: downloading component 'rust-std'
info: downloading component 'cargo'
info: downloading component 'rust-docs'
info: installing component 'rustc'
info: installing component 'rust-std'
info: installing component 'cargo'
info: installing component 'rust-docs'
error: failed to parse lock file at: /home/dependabot/dependabot-updater/dependabot_tmp_dir/Cargo.lock

Caused by:
  package `juniper` is specified twice in the lockfile

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Update example for rocket_contrib::databases?

I already have a recent Rocket application that uses the rocket_contrib::database module.
This seemed to me, as a beginner, the easier way to integrate a database using the Diesel driver.
However, I cannot seem to make it work if I try to adapt this example for it?

Given I have:

#[database("foo_db")]
pub struct DbConn(diesel::SqliteConnection);

I tried to put a DbConn in Context, but that doesn't seem to be possible; DbConn does not implement Sync? I also tried to use DbConn as Context, given that FromRequest is implemented but then I really get pages of warnings that I will not repeat here.

Would you consider adapting the example to use rocket_contrib::databases instead of a custom DB pooling implementation?

Interface example

How would an interface be implemented in this example?

I'm thinking of something like in the official example to both list all the Characters or only Humans or Droids.

How would juniper-from-schema and juniper-eager-loading be used together with Diesel to avoid N+1 queries in these lists?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.