Giter VIP home page Giter VIP logo

rust-graphql-docker's Introduction

Dockerize Graphql Rust

More current version at https://github.com/jayy-lmao/rust-cult-graphql-server

This project is currently for demonstrating the use of dataloaders in a rust-based graphql server. This demo uses:

There are definitely some improvements to be made in db requests, pagination etc. Let me know if you spot anything you think is top-priority!

Running locally

simple as docker-compose up, crazy! Then navigate to http://localhost:8000/graphql

TODO

  • DB connection
  • Expose graphql
  • Mutations!
    • Create
    • Update
    • Delete
  • Context to later use in Dataloaders and Auth
  • Dataloaders
  • Auth?
  • DB pool

Schema

type Cult {
  id: Int!
  name: String!
  members: [Person!]!
}

type Mutation {
  createPerson(data: NewPerson!): Person!
  createCult(data: NewCult!): Cult!
}

input NewCult {
  name: String!
}

input NewPerson {
  name: String!
  cult: Int
}

type Person {
  id: Int!
  name: String!
  cult: Cult
}

type Query {
  personById(id: Int!): Person!
  persons: [Person!]!
  cultById(id: Int!): Cult!
  cults: [Cult!]!
}

References

Original Rest API & DB connection is inspired by: https://turreta.com/2019/09/21/rest-api-with-rust-actix-web-and-postgresql-part-3/

Graphql setup is inspired by: https://www.freecodecamp.org/news/building-powerful-graphql-servers-with-rust/

Rust containerization initially inspired by: https://alexbrand.dev/post/how-to-package-rust-applications-into-minimal-docker-containers/

Other stuff

If you are ever looking at setting up a Redis pubsub for keeping multiple servers in sync; check out https://github.com/jayy-lmao/rust-chat-bb8-ws

If you want a more up-to-date version using actix-web and async-graphql see https://github.com/jayy-lmao/rust-cult-graphql-server

rust-graphql-docker's People

Contributors

jayy-lmao avatar nemesiscodex avatar tylerhjones avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rust-graphql-docker's Issues

Missing DB column error for cults query

There's a missing column issue with the db. Not sure what changed, but will have to go fix it.

api_1  | Connection is fine
db_1   | 2021-05-15 00:34:49.446 UTC [105] ERROR:  column "cult" does not exist at character 18
db_1   | 2021-05-15 00:34:49.446 UTC [105] STATEMENT:  SELECT id, name, cult FROM cults
api_1  | thread 'actix-rt:worker:2' panicked at 'called `Result::unwrap()` on an `Err` value: Error(Db(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("42703"), message: "column \"cult\" does not exist", detail: None, hint: None, position: Some(Normal(18)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("parse_relation.c"), line: Some(3359), routine: Some("errorMissingColumn") }))', src/data/cult/get_cult_all.rs:8:69
api_1  | stack backtrace:
api_1  |    0: rust_begin_unwind
api_1  |              at ./rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
api_1  |    1: core::panicking::panic_fmt
api_1  |              at ./rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:92:14
api_1  |    2: core::option::expect_none_failed
api_1  |              at ./rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/option.rs:1300:5
api_1  |    3: rust_graphql::data::cult::get_cult_all::get_cult_all
api_1  |    4: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
api_1  |    5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
api_1  |    6: futures_util::stream::stream::StreamExt::poll_next_unpin
api_1  |    7: futures_util::stream::stream::StreamExt::poll_next_unpin
api_1  |    8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
api_1  |    9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
api_1  |   10: juniper::execute_async::{{closure}}
api_1  |   11: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
api_1  |   12: std::thread::local::LocalKey<T>::with
api_1  |   13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
api_1  |   14: <actix_web::handler::HandlerServiceResponse<T,R> as core::future::future::Future>::poll
api_1  |   15: <actix_web::handler::ExtractResponse<T,S> as core::future::future::Future>::poll
api_1  |   16: <actix_web::handler::ExtractResponse<T,S> as core::future::future::Future>::poll
api_1  |   17: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
api_1  |   18: <core::pin::Pin<P> as core::future::future::Future>::poll
api_1  |   19: <futures_util::future::either::Either<A,B> as core::future::future::Future>::poll
api_1  |   20: actix_http::h1::dispatcher::InnerDispatcher<T,S,B,X,U>::poll_response
api_1  |   21: <actix_http::h1::dispatcher::Dispatcher<T,S,B,X,U> as core::future::future::Future>::poll
api_1  |   22: <actix_service::and_then::AndThenServiceResponse<A,B> as core::future::future::Future>::poll
api_1  |   23: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
api_1  |   24: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
api_1  |   25: tokio::task::harness::Harness<T,S>::poll
api_1  |   26: tokio::task::local::Scheduler::tick
api_1  |   27: std::thread::local::LocalKey<T>::with
api_1  |   28: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
api_1  |   29: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on
api_1  |   30: tokio::runtime::context::enter
api_1  | note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.```

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.