Open8
GraphQLの理解を深めるための試行錯誤
やること
・Nestjsを使ってGraphQLサーバーの立ち上げ-ShopNameが返ってくるサンプル
・ApolloServerを使ってGraphQLサーバーの立ち上げ-shopNameが返ってくるサンプル
・graphql codegenを利用して自動生成されたファイルを活用
$ npm i -g @nestjs/cli
$ nest new project-name
# For Express and Apollo (default)
$ npm i @nestjs/graphql @nestjs/apollo @apollo/server graphql
.gitの入っているプロジェクトだったのでcodespaceがgitしてくれなくなる。
.gitを削除
こちらを参考に進めていくが、少し違うので、
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
'@nestjs/graphql'のライブラリを使う。
codegenちゃんと読まなきゃ。
いろいろ出来ること多い。shopify と codegenを使っている記事