// 21.11.24 스터디 정리
Query/ Mutation
쿼리는 읽는데 사용하고(R), 뮤테이션은 데이터를 변조함(CUD)
query: 데이터를 받아올 때 사용한다.
mutation: 데이터를 생성, 수정, 삭제할 때 사용한다.
subscription: 웹소켓을 사용해 실시간 양방향 통신을 구현할 때 사용한다.
React Apollo client 경우에는 variables 라는 파라메터에 원하는 값을 넣어주면 됨
query getStudentInfomation($studentId: ID){
personalInfo(studentId: $studentId) {
name
address1
address2
major
}
classInfo(year: 2018, studentId: $studentId) {
classCode
className
teacher {
name
major
}
classRoom {
id
maintainer {
name
}
}
}
SATInfo(schoolCode: 0412, studentId: $studentId) {
totalScore
dueDate
}
}
type Character {
name: String!
appearsIn: [Episode!]!
}
type user {
name: String
email: String
phoneNumber: String
}
참고: https://velog.io/@bangina/Apollo-client-GraphQL-React.js-의-모든-것
객체로 바독 개체로 반환한다 (Receive and objext, return an object)
구조분해 할당