Skip to content

Commit c98cc26

Browse files
committed
Rustfmt
1 parent ffb8cb9 commit c98cc26

File tree

28 files changed

+180
-115
lines changed

28 files changed

+180
-115
lines changed

.rustfmt.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
edition = "2021"
2+
newline_style = "Unix"
3+
# comments
4+
normalize_comments = true
5+
wrap_comments = true
6+
format_code_in_doc_comments = true
7+
# imports
8+
imports_granularity = "Crate"
9+
group_imports = "StdExternalCrate"
10+
# report
11+
#report_fixme="Unnumbered"
12+
#report_todo="Unnumbered"

actix-web/error-extensions/src/main.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#[macro_use]
22
extern crate thiserror;
33

4-
use actix_web::web::Data;
5-
use actix_web::{guard, web, App, HttpResponse, HttpServer};
6-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
4+
use actix_web::{guard, web, web::Data, App, HttpResponse, HttpServer};
75
use async_graphql::{
6+
http::{playground_source, GraphQLPlaygroundConfig},
87
EmptyMutation, EmptySubscription, ErrorExtensions, FieldError, FieldResult, Object, ResultExt,
98
Schema,
109
};
@@ -49,8 +48,8 @@ impl QueryRoot {
4948
.map_err(|e: std::num::ParseIntError| e.extend_with(|_, e| e.set("code", 404)))?)
5049
}
5150

52-
// THIS does unfortunately NOT work because ErrorExtensions is implemented for &E and not E.
53-
// Which is necessary for the overwrite by the user.
51+
// THIS does unfortunately NOT work because ErrorExtensions is implemented for
52+
// &E and not E. Which is necessary for the overwrite by the user.
5453

5554
// async fn parse_with_extensions_result(&self) -> FieldResult<i32> {
5655
// Ok("234a".parse().extend_err(|_| json!({"code": 404}))?)

actix-web/starwars/src/main.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use actix_web::web::Data;
2-
use actix_web::{guard, web, App, HttpResponse, HttpServer, Result};
3-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
4-
use async_graphql::{EmptyMutation, EmptySubscription, Schema};
1+
use actix_web::{guard, web, web::Data, App, HttpResponse, HttpServer, Result};
2+
use async_graphql::{
3+
http::{playground_source, GraphQLPlaygroundConfig},
4+
EmptyMutation, EmptySubscription, Schema,
5+
};
56
use async_graphql_actix_web::{GraphQLRequest, GraphQLResponse};
67
use starwars::{QueryRoot, StarWars, StarWarsSchema};
78

actix-web/subscription/src/main.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use actix_web::web::Data;
2-
use actix_web::{guard, web, App, HttpRequest, HttpResponse, HttpServer, Result};
3-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
4-
use async_graphql::Schema;
1+
use actix_web::{guard, web, web::Data, App, HttpRequest, HttpResponse, HttpServer, Result};
2+
use async_graphql::{
3+
http::{playground_source, GraphQLPlaygroundConfig},
4+
Schema,
5+
};
56
use async_graphql_actix_web::{GraphQLRequest, GraphQLResponse, GraphQLSubscription};
67
use books::{BooksSchema, MutationRoot, QueryRoot, Storage, SubscriptionRoot};
78

actix-web/token-from-header/src/main.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
use actix_web::http::header::HeaderMap;
2-
use actix_web::{guard, web, App, HttpRequest, HttpResponse, HttpServer, Result};
3-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
4-
use async_graphql::{Data, EmptyMutation, Schema};
1+
use actix_web::{
2+
guard, http::header::HeaderMap, web, App, HttpRequest, HttpResponse, HttpServer, Result,
3+
};
4+
use async_graphql::{
5+
http::{playground_source, GraphQLPlaygroundConfig},
6+
Data, EmptyMutation, Schema,
7+
};
58
use async_graphql_actix_web::{GraphQLRequest, GraphQLResponse, GraphQLSubscription};
69
use token::{on_connection_init, QueryRoot, SubscriptionRoot, Token, TokenSchema};
710

actix-web/upload/src/main.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use actix_web::web::Data;
2-
use actix_web::{guard, web, App, HttpResponse, HttpServer};
3-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig, MultipartOptions};
4-
use async_graphql::{EmptySubscription, Schema};
1+
use actix_web::{guard, web, web::Data, App, HttpResponse, HttpServer};
2+
use async_graphql::{
3+
http::{playground_source, GraphQLPlaygroundConfig, MultipartOptions},
4+
EmptySubscription, Schema,
5+
};
56
use async_graphql_actix_web::{GraphQLRequest, GraphQLResponse};
67
use files::{FilesSchema, MutationRoot, QueryRoot, Storage};
78

axum/starwars/src/main.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
2-
use async_graphql::{EmptyMutation, EmptySubscription, Schema};
1+
use async_graphql::{
2+
http::{playground_source, GraphQLPlaygroundConfig},
3+
EmptyMutation, EmptySubscription, Schema,
4+
};
35
use async_graphql_axum::{GraphQLRequest, GraphQLResponse};
4-
use axum::extract::Extension;
5-
use axum::response::{self, IntoResponse};
6-
use axum::routing::get;
7-
use axum::{Router, Server};
6+
use axum::{
7+
extract::Extension,
8+
response::{self, IntoResponse},
9+
routing::get,
10+
Router, Server,
11+
};
812
use starwars::{QueryRoot, StarWars, StarWarsSchema};
913

1014
async fn graphql_handler(

axum/subscription/src/main.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
2-
use async_graphql::Schema;
1+
use async_graphql::{
2+
http::{playground_source, GraphQLPlaygroundConfig},
3+
Schema,
4+
};
35
use async_graphql_axum::{GraphQLRequest, GraphQLResponse, GraphQLSubscription};
4-
use axum::response::{self, IntoResponse};
5-
use axum::routing::get;
6-
use axum::{extract::Extension, Router, Server};
6+
use axum::{
7+
extract::Extension,
8+
response::{self, IntoResponse},
9+
routing::get,
10+
Router, Server,
11+
};
712
use books::{BooksSchema, MutationRoot, QueryRoot, Storage, SubscriptionRoot};
813

914
async fn graphql_handler(schema: Extension<BooksSchema>, req: GraphQLRequest) -> GraphQLResponse {

axum/upload/src/main.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
2-
use async_graphql::{EmptySubscription, Schema};
1+
use async_graphql::{
2+
http::{playground_source, GraphQLPlaygroundConfig},
3+
EmptySubscription, Schema,
4+
};
35
use async_graphql_axum::{GraphQLRequest, GraphQLResponse};
4-
use axum::extract::Extension;
5-
use axum::response::{Html, IntoResponse};
6-
use axum::routing::get;
7-
use axum::Router;
6+
use axum::{
7+
extract::Extension,
8+
response::{Html, IntoResponse},
9+
routing::get,
10+
Router,
11+
};
812
use files::{FilesSchema, MutationRoot, QueryRoot, Storage};
913
use hyper::{Method, Server};
1014
use tower_http::cors::{CorsLayer, Origin};

federation/federation-accounts/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
use std::convert::Infallible;
2+
13
use async_graphql::{EmptyMutation, EmptySubscription, Object, Schema, SimpleObject, ID};
24
use async_graphql_warp::graphql;
3-
use std::convert::Infallible;
45
use warp::{Filter, Reply};
56

67
#[derive(SimpleObject)]

federation/federation-products/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
use std::convert::Infallible;
2+
13
use async_graphql::{Context, EmptyMutation, EmptySubscription, Object, Schema, SimpleObject};
24
use async_graphql_warp::graphql;
3-
use std::convert::Infallible;
45
use warp::{Filter, Reply};
56

67
#[derive(SimpleObject)]

federation/federation-reviews/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
use std::convert::Infallible;
2+
13
use async_graphql::{Context, EmptyMutation, EmptySubscription, Object, Schema, SimpleObject, ID};
24
use async_graphql_warp::graphql;
3-
use std::convert::Infallible;
45
use warp::{Filter, Reply};
56

67
struct User {

models/books/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
mod simple_broker;
22

3+
use std::{sync::Arc, time::Duration};
4+
35
use async_graphql::{Context, Enum, Object, Result, Schema, Subscription, ID};
4-
use futures_util::lock::Mutex;
5-
use futures_util::{Stream, StreamExt};
6+
use futures_util::{lock::Mutex, Stream, StreamExt};
67
use simple_broker::SimpleBroker;
78
use slab::Slab;
8-
use std::sync::Arc;
9-
use std::time::Duration;
109

1110
pub type BooksSchema = Schema<QueryRoot, MutationRoot, SubscriptionRoot>;
1211

models/books/src/simple_broker.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
use std::any::{Any, TypeId};
2-
use std::collections::HashMap;
3-
use std::marker::PhantomData;
4-
use std::pin::Pin;
5-
use std::sync::Mutex;
6-
use std::task::{Context, Poll};
1+
use std::{
2+
any::{Any, TypeId},
3+
collections::HashMap,
4+
marker::PhantomData,
5+
pin::Pin,
6+
sync::Mutex,
7+
task::{Context, Poll},
8+
};
79

810
use futures_channel::mpsc::{self, UnboundedReceiver, UnboundedSender};
911
use futures_util::{Stream, StreamExt};

models/starwars/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
mod model;
22

3-
use async_graphql::{EmptyMutation, EmptySubscription, Schema};
4-
use model::Episode;
5-
use slab::Slab;
63
use std::collections::HashMap;
74

5+
use async_graphql::{EmptyMutation, EmptySubscription, Schema};
6+
use model::Episode;
87
pub use model::QueryRoot;
8+
use slab::Slab;
99
pub type StarWarsSchema = Schema<QueryRoot, EmptyMutation, EmptySubscription>;
1010

1111
pub struct StarWarsChar {

models/starwars/src/model.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#![allow(clippy::needless_lifetimes)]
22

3+
use async_graphql::{
4+
connection::{query, Connection, Edge, EmptyFields},
5+
Context, Enum, Error, Interface, Object, Result,
6+
};
7+
38
use super::StarWars;
49
use crate::StarWarsChar;
5-
use async_graphql::connection::{query, Connection, Edge, EmptyFields};
6-
use async_graphql::{Context, Enum, Error, Interface, Object, Result};
710

811
/// One of the films in the Star Wars Trilogy
912
#[derive(Enum, Copy, Clone, Eq, PartialEq)]

poem/starwars/src/main.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
2-
use async_graphql::{EmptyMutation, EmptySubscription, Schema};
1+
use async_graphql::{
2+
http::{playground_source, GraphQLPlaygroundConfig},
3+
EmptyMutation, EmptySubscription, Schema,
4+
};
35
use async_graphql_poem::GraphQL;
4-
use poem::listener::TcpListener;
5-
use poem::web::Html;
6-
use poem::{get, handler, IntoResponse, Route, Server};
6+
use poem::{get, handler, listener::TcpListener, web::Html, IntoResponse, Route, Server};
77
use starwars::{QueryRoot, StarWars};
88

99
#[handler]

poem/subscription-redis/src/main.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
2-
use async_graphql::{Context, Object, Result, Schema, Subscription};
1+
use async_graphql::{
2+
http::{playground_source, GraphQLPlaygroundConfig},
3+
Context, Object, Result, Schema, Subscription,
4+
};
35
use async_graphql_poem::{GraphQL, GraphQLSubscription};
46
use futures_util::{Stream, StreamExt};
5-
use poem::listener::TcpListener;
6-
use poem::web::Html;
7-
use poem::{get, handler, IntoResponse, Route, Server};
7+
use poem::{get, handler, listener::TcpListener, web::Html, IntoResponse, Route, Server};
88
use redis::{AsyncCommands, Client};
99

1010
struct QueryRoot;

poem/subscription/src/main.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
2-
use async_graphql::Schema;
1+
use async_graphql::{
2+
http::{playground_source, GraphQLPlaygroundConfig},
3+
Schema,
4+
};
35
use async_graphql_poem::{GraphQL, GraphQLSubscription};
46
use books::{MutationRoot, QueryRoot, Storage, SubscriptionRoot};
5-
use poem::listener::TcpListener;
6-
use poem::web::Html;
7-
use poem::{get, handler, IntoResponse, Route, Server};
7+
use poem::{get, handler, listener::TcpListener, web::Html, IntoResponse, Route, Server};
88

99
#[handler]
1010
async fn graphql_playground() -> impl IntoResponse {

poem/token-from-header/src/main.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig, ALL_WEBSOCKET_PROTOCOLS};
2-
use async_graphql::{EmptyMutation, Schema};
1+
use async_graphql::{
2+
http::{playground_source, GraphQLPlaygroundConfig, ALL_WEBSOCKET_PROTOCOLS},
3+
EmptyMutation, Schema,
4+
};
35
use async_graphql_poem::{GraphQLProtocol, GraphQLRequest, GraphQLResponse, GraphQLWebSocket};
4-
use poem::http::HeaderMap;
5-
use poem::listener::TcpListener;
6-
use poem::web::{websocket::WebSocket, Data, Html};
7-
use poem::{get, handler, EndpointExt, IntoResponse, Route, Server};
6+
use poem::{
7+
get, handler,
8+
http::HeaderMap,
9+
listener::TcpListener,
10+
web::{websocket::WebSocket, Data, Html},
11+
EndpointExt, IntoResponse, Route, Server,
12+
};
813
use token::{on_connection_init, QueryRoot, SubscriptionRoot, Token, TokenSchema};
914

1015
fn get_token_from_headers(headers: &HeaderMap) -> Option<Token> {

poem/upload/src/main.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
2-
use async_graphql::{EmptySubscription, Schema};
1+
use async_graphql::{
2+
http::{playground_source, GraphQLPlaygroundConfig},
3+
EmptySubscription, Schema,
4+
};
35
use async_graphql_poem::{GraphQLRequest, GraphQLResponse};
46
use files::{FilesSchema, MutationRoot, QueryRoot, Storage};
5-
use poem::listener::TcpListener;
6-
use poem::middleware::Cors;
7-
use poem::web::{Data, Html};
8-
use poem::{get, handler, EndpointExt, IntoResponse, Route, Server};
7+
use poem::{
8+
get, handler,
9+
listener::TcpListener,
10+
middleware::Cors,
11+
web::{Data, Html},
12+
EndpointExt, IntoResponse, Route, Server,
13+
};
914

1015
#[handler]
1116
async fn index(schema: Data<&FilesSchema>, req: GraphQLRequest) -> GraphQLResponse {

tide/dataloader-postgres/src/main.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
use async_graphql::dataloader::{DataLoader, Loader};
2-
use async_graphql::futures_util::TryStreamExt;
3-
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
1+
use std::{collections::HashMap, env};
2+
43
use async_graphql::{
4+
dataloader::{DataLoader, Loader},
5+
futures_util::TryStreamExt,
6+
http::{playground_source, GraphQLPlaygroundConfig},
57
Context, EmptyMutation, EmptySubscription, FieldError, Object, Result, Schema, SimpleObject,
68
};
79
use async_std::task;
810
use async_trait::async_trait;
911
use itertools::Itertools;
1012
use sqlx::{Pool, Postgres};
11-
use std::collections::HashMap;
12-
use std::env;
1313
use tide::{http::mime, Body, Response, StatusCode};
1414

1515
#[derive(sqlx::FromRow, Clone, SimpleObject)]
@@ -121,10 +121,12 @@ async fn run() -> Result<()> {
121121

122122
#[cfg(test)]
123123
mod tests {
124-
use super::*;
124+
use std::time::Duration;
125+
125126
use async_std::prelude::*;
126127
use serde_json::{json, Value};
127-
use std::time::Duration;
128+
129+
use super::*;
128130

129131
#[test]
130132
fn sample() -> Result<()> {

0 commit comments

Comments
 (0)