yarn add jest supertest @types/jest @types/supertest -D
yarn add --dev ts-jest @types/jest
- app.ts に graphql の設定を追加
- テストファイル追加
mutation {
createUser(name: "John Doe", email: "john@example.com") {
id
name
email
}
}
{
user(id: 1) {
id
name
email
}
}
```
```gql
{
users {
id
name
email
}
}
mutation {
updateUser(id: 1, name: "Jane Doe", email: "jane@example.com") {
id
name
email
}
}
mutation {
deleteUser(id: 1) {
id
}
}
yarn add express graphql express-graphql sqlite3
yarn add -D typescript ts-node @types/node @types/express @types/graphql @types/sqlite3
- db.ts 作成
- schema.ts 作成
- resolvers.ts 作成
- routes/index.ts 修正
yarn dev してからクエリを叩いて動作確認
{
user(id: 1) {
id
name
email
}
}
yarn add --dev typescript @types/node && yarn tsc --init && yarn add --dev ts-node && yarn add --dev @types/express && yarn add --dev @types/cookie-parser @types/morgan
"scripts": {
"start": "ts-node routes/index.ts"
},
- js -> ts で拡張子変更
- ともなって内容も変更。
- build: ビルドシステムや外部依存関係の変更
- chore: 雑用。ビルドプロセスや補助ツールの変更
- ci: CI の設定やスクリプトの変更
- docs: ドキュメントのみの変更
- feat: 新機能の追加
- fix: バグ修正
- perf: パフォーマンスを向上させるコードの変更
- refactor: リファクタリング
- revert: コードの変更を取り消す
- style: コードの意味に影響を与えない変更(空白、フォーマット、セミコロンの欠落など)
- test: テストの追加、変更、削除
- 公式を参考