Open8

GraphQLの理解を深めるための試行錯誤

百田行宏百田行宏

やること
・Nestjsを使ってGraphQLサーバーの立ち上げ-ShopNameが返ってくるサンプル
・ApolloServerを使ってGraphQLサーバーの立ち上げ-shopNameが返ってくるサンプル
・graphql codegenを利用して自動生成されたファイルを活用

百田行宏百田行宏
# For Express and Apollo (default)
$ npm i @nestjs/graphql @nestjs/apollo @apollo/server graphql
百田行宏百田行宏

.gitの入っているプロジェクトだったのでcodespaceがgitしてくれなくなる。
.gitを削除

百田行宏百田行宏

https://tech.fusic.co.jp/posts/2019-09-29-nestjs-graphql/
こちらを参考に進めていくが、少し違うので、

npm install type-graphql
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: nestjs@0.0.1
npm ERR! Found: graphql@16.6.0
npm ERR! node_modules/graphql
npm ERR!   graphql@"^16.6.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer graphql@"^15.3.0" from type-graphql@1.1.1
npm ERR! node_modules/type-graphql
npm ERR!   type-graphql@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /home/vscode/.npm/_logs/2023-04-30T06_13_33_953Z-eresolve-report.txt

https://github.com/nestjs/nest/blob/master/sample/23-graphql-code-first/src/recipes/models/recipe.model.ts
と合体。
'@nestjs/graphql'のライブラリを使う。