Skip to content

Commit

Permalink
📝 docs
Browse files Browse the repository at this point in the history
  • Loading branch information
James Holman committed Jan 29, 2020
1 parent d9c2b81 commit cca9603
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 35 deletions.
54 changes: 27 additions & 27 deletions api/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "readspacer-api"
name = "rust-graphql"
version = "0.1.0"
authors = ["Jayy-Lmao <jameswarringtonholman@gmail.com>"]
edition = "2018"
Expand Down Expand Up @@ -32,5 +32,5 @@ serde_json = "1.0"
thiserror = "1.0"

[[bin]]
name = "readspacer-api"
name = "rust-graphql"
path = "src/main.rs"
8 changes: 4 additions & 4 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ ENV RUST_TARGETS="x86_64-unknown-linux-musl"
RUN rustup target install x86_64-unknown-linux-musl

# Creating a placeholder project
RUN USER=root cargo new readspacer-api
WORKDIR /usr/src/readspacer-api
RUN USER=root cargo new rust-graphql
WORKDIR /usr/src/rust-graphql

# moving deps info
COPY ./Cargo.lock ./Cargo.lock
Expand All @@ -31,6 +31,6 @@ RUN cargo build --target x86_64-unknown-linux-musl --release

# This creates a TINY container with the executable! Like 4-5mb srsly
FROM scratch
COPY --from=build /usr/src/readspacer-api/target/x86_64-unknown-linux-musl/release/readspacer-api .
COPY --from=build /usr/src/rust-graphql/target/x86_64-unknown-linux-musl/release/rust-graphql .
USER 1000
CMD ["./readspacer-api"]
CMD ["./rust-graphql"]
9 changes: 7 additions & 2 deletions api/src/graphql/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ pub async fn graphql(
data: web::Json<GraphQLRequest>,
) -> Result<HttpResponse, Error> {
let mut rt = futures::executor::LocalPool::new();

// Context setup
let person_data = PersonData::new();
let cult_data = CultData::new();
let ctx = Context::new(person_data, cult_data);
let f = data.execute_async(&st, &ctx);
let res = rt.run_until(f);

// Execute
let future_execute = data.execute_async(&st, &ctx);
let res = rt.run_until(future_execute);
let json = serde_json::to_string(&res).map_err(error::ErrorInternalServerError)?;

Ok(
Expand All @@ -24,6 +28,7 @@ pub async fn graphql(
}

pub fn playground() -> HttpResponse {
// I prefer playground but you can use graphiql as well
let html = playground_source("http://localhost:8000/graphql");
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
Expand Down
Binary file removed database/.create_users.sql.swp
Binary file not shown.

0 comments on commit cca9603

Please sign in to comment.