개발
-
GraphQL Mutation 스키마 만들어 delete,edit 해보기개발 2020. 2. 12. 20:31
Mutation 은 데이터를 추가 수정 삭제등 할때 사용한다. 다음은 user를 add 해볼것이다. Root Query 처럼 Mutation 을 작성한다. const mutation = new GraphQLObjectType({ name:'Mutation', fields:{ addUser:{ type:UserType, args:{ firstName:{type:new GraphQLNonNull(GraphQLString)}, age:{type:new GraphQLNonNull(GraphQLInt)}, companyId:{type:new GraphQLNonNull(GraphQLString)}, }, resolve(parentValue,{firstName,age}){ return axios.post(`http:..
-
graphql 데이터 api만들고 연동 , 타입관 관계형성하기개발 2020. 2. 11. 20:06
api를 만들기 위해서 json-server사용한다. fake db를 만들어보자 db.json { "Users":[ { "id":"1","firstName":"Hwi","age":31 }, { "id":"2","firstName":"Yunji","age":25 } ] } 이후 package.json 에서 "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "json:server":"json-server --watch db.json" }, 해당 json:server 스크립트를 넣어주고 두번째 터미널을 열어 (server돌아가는중) npm run json:server를 실행한다. 이와같이 3000포트로 api 를 만들수있다. /Users/..
-
graphql 시작하기개발 2020. 1. 28. 19:37
const express = require('express'); const app = express(); const expressGraphQL = require('express-graphql'); app.use('graphql',expressGraphQL({ graphiql:true })) app.listen(4000,()=>{ console.log('listening'); }) express-graphql은 express와 graphql 을 이어준다. '/graphql' url 이 뜨면 expressGraphql을 메소드실행해 graphql을 사용한다. 먼저 스키마를 만들어야한다. const graphql = require('graphql'); const {GraphQLObjectType} = grap..
-
react firebase 연동 auth 정보 db, app에 저장하기개발 2020. 1. 7. 20:51
firebase.initializeApp(config); firebase 를 처음 실행할때 필요하다. config 에서는 firebase에서 제공하는 api key 등등의 정보들이 들어있다. export const auth = firebase.auth(); export const firestore = firebase.firestore(); firebase 의 auth, firestore 메소드를 불러온다 auth 는 이후 app.js 에서 사용할것이다. const provider = new firebase.auth.GoogleAuthProvider(); //auth 라이브러리 접근가능 provider.setCustomParameters({prompt:'select_account'}) // pop up G..