#graphql #graphql-schema #generation

app codegen-for-async-graphql

async-graphql 的内部代码生成库

3 个版本

0.2.6 2020 年 7 月 9 日
0.2.5 2020 年 7 月 9 日
0.1.0 2020 年 7 月 6 日

#11 in #async-graphql

26 每月下载量

MIT 协议

77KB
2K SLoC

codegen-for-async-graphql

codecov

使用方法

cargo codegen-for-async-graphql --schema {path_to_schema} --output {path_to_output}
# cargo codegen-for-async-graphql --schema ./schema.graphql --output src/models
mod models;

use async_graphql::*;

use models::{
  Mutation, Query,
};

let data_source = DataSource {};
let schema = Schema::build(Query {}, Mutation {}, EmptySubscription)
    .register_type::<User>()
    .data(data_source)
    .finish();
let res = schema.execute(query).await;
let json = serde_json::to_string_pretty(&async_graphql::http::GQLResponse(res));
json.unwrap()

依赖项

~19–32MB
~578K SLoC