node.js + react.js + react native + prisma + GraphQL
npm install graphql-yoga
npm install nodemon -D
npm install dotenv -D
npm install @babel/preset-env -D
npm install @babel/core -D
npm install @babel/node -D
npm install morgan -D
npm install eslint-config-airbnb-base
npx install-peerdeps --dev eslint-config-airbnb
#! package.json
"eslintConfig": {
"extends": "airbnb"
}
npm install graphql-tools merge-graphql-schemas --save
npm install prisma
npm install --save prisma-client-lib
prisma init
prisma deploy
: schema of datamodel.prisma migrateprisma generate
: create prisma client
import .env
Using GraphQL Server
datamodel.prisma
-> models.graphql
db model schema
create folder
.graphql
(query type) + .js
(query resolvers)
#! src/schema.js
const allTypes = fileLoader(path.join(__dirname, '/api/**/*.graphql'));
const allResolvers = fileLoader(path.join(__dirname, '/api/**/*.js'));
const schema = makeExecutableSchema({
typeDefs: mergeTypes(allTypes),
resolvers: mergeResolvers(allResolvers),
});
#! src/server.js
const server = new GraphQLServer({
schema,
});
utility functions
npm install --save nodemailer
npm install --save nodemailer-sendgrid-transport
npm install passport passport-jwt
passport는 인증관련 일처리. jwt 토큰이나 쿠키에서 정보를 가져와 사용자 정보에 serialize(저장)함. 토큰을 해독 후 사용자 객체를 request에 추가.