TypeGraphQL
https://gyazo.com/dedb9bb410424261f5add71282706acf
Code First
coreでGraphQL.jsを使っている
website
docs
github
#WIP
examples
https://github.com/arcticmatt/graphql_server_typegraphql
#??
ディレクトリ構成
class-validatorってなに?
decoratorでvalidationを書くlibraryか
Getting Startedをやる
https://typegraphql.com/docs/getting-started.html
#??
class propertyの初期化子がないよとめっちゃ言われるんだけど
tsconfigのルールを弱くするしか無いの?
NewRecipeInputとRecipesArgsっってどういう立ち位置?
resolverでもschemaでもないのか?
RecipeServiceってなんだ?
何の説明もない
コード上に現れるdecoratorはいくつか種類があるっぽい
type用のもの
resolver用のもの
class-validatorが提供するもの
実装のフロー
classで型を定義する
decoratorsでdecorateする
resolverを作る
CRUDのため
typeのdecorators
ObjectType
Field
resolverのdecorators
https://typegraphql.com/docs/resolvers.html
Resolver,
Query,
Arg,
Args,
Mutation,
Authorized,
Ctx
classとTypeScriptのdecoratorでschema定義をする
例
code:ts
@ObjectType()
class Recipe {
@Field(type => ID)
id: string;
@Field()
title: string;
@Field(type => Rate)
ratings: Rate[];
@Field({ nullable: true })
averageRating?: number;
}
解説シリーズ
https://www.youtube.com/watch?v=8yZImm2A1KE&list=PLN3n1USn4xlma1bBu3Tloe4NyYn9Ko8Gs