Skip to content

Commit

Permalink
fix graphql path
Browse files Browse the repository at this point in the history
  • Loading branch information
tom1484 committed Dec 1, 2023
1 parent 4bef633 commit 7072853
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions editor-server/src/graphql/mutations/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl ColorMutation {
.await?;

let color_payload = ColorPayload {
mutation: ColorMutationMode::UPDATED,
mutation: ColorMutationMode::Updated,
id,
color: Some(data.color.clone()),
color_code: Some(data.color_code.clone()),
Expand Down Expand Up @@ -91,7 +91,7 @@ impl ColorMutation {
.last_insert_id() as i32;

let color_payload = ColorPayload {
mutation: ColorMutationMode::CREATED,
mutation: ColorMutationMode::Created,
id,
color: Some(data.color.clone()),
color_code: Some(data.color_code.clone()),
Expand Down Expand Up @@ -140,7 +140,7 @@ impl ColorMutation {
.await?;

let color_payload = ColorPayload {
mutation: ColorMutationMode::DELETED,
mutation: ColorMutationMode::Deleted,
id,
color: None,
color_code: None,
Expand Down
12 changes: 8 additions & 4 deletions editor-server/src/graphql/subscriptions/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ use crate::graphql::subscriptor::Subscriptor;

use async_graphql::{Enum, SimpleObject, Subscription};
use futures_core::stream::Stream;
use serde::{Deserialize, Serialize};

#[derive(Enum, Clone, Copy, Eq, PartialEq, Default)]
#[derive(Enum, Clone, Copy, Eq, PartialEq, Default, Serialize, Deserialize)]
pub enum ColorMutationMode {
#[default]
UPDATED,
CREATED,
DELETED,
#[serde(rename = "UPDATED")]
Updated,
#[serde(rename = "CREATED")]
Created,
#[serde(rename = "DELETED")]
Deleted,
}

#[derive(SimpleObject, Clone, Default)]
Expand Down
2 changes: 1 addition & 1 deletion editor-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async fn main() {

println!("Server is ready!");
println!("Listening on port {}", server_port);
println!("GraphiQL: http://localhost:{}/graphql", server_port);
println!("GraphiQL: http://localhost:{}/graphql-backend", server_port);

axum::Server::bind(&format!("0.0.0.0:{}", server_port).parse().unwrap())
.serve(app.into_make_service())
Expand Down
8 changes: 4 additions & 4 deletions editor-server/src/routes/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ async fn graphql(
async fn graphiql() -> impl IntoResponse {
Html(
GraphiQLSource::build()
.endpoint("/graphql")
.subscription_endpoint("/graphql-websocket")
.endpoint("/graphql-backend")
.subscription_endpoint("/graphql-backend-websocket")
.finish(),
)
}

pub fn build_graphql_routes(schema: AppSchema) -> Router {
Router::new()
// Main routes for GraphQL
.route("/graphql", get(graphiql).post(graphql))
.route("/graphql-backend", get(graphiql).post(graphql))
// Websocket route for GraphQL subscriptions with connection and disconnection callbacks
.route(
"/graphql-websocket",
"/graphql-backend-websocket",
get_service(GraphQLSubscription::new(ws_on_connect, ws_on_disconnect)),
)
// Pass schema as extension to routes
Expand Down

0 comments on commit 7072853

Please sign in to comment.