0
나는 클라이언트에 데이터를 리턴 할 리졸버 (resolver)를위한 시점 인 apollo/postgres/sequelize에서 첫 번째 관계형 데이터베이스 스키마/쿼리/리졸버를 사용했다. 분명히 나는 올바른 모양의 데이터를 가지고 있지 않다. 왜냐하면 그것은 클라이언트에서 null이 오기 때문이다.Apollo : 서버 응답의 필수 모양?
QUERY
const CREATE_APPT_MUTATION = gql`
mutation createAPPT ($originatingUserID: String!, $apptWithUserID: String!, $apptDateTime: String!, $apptNotes: String!, $apptTitle: String!){
createAPPT(originatingUserID: $originatingUserID, apptWithUserID: $apptWithUserID, apptDateTime: $apptDateTime, apptNotes: $apptNotes, apptTitle: $apptTitle){
originatingUserID
apptWithUserID
apptDateTime
apptNotes
apptTitle
}
}
`;
RESOLVER의 응답의 현재 SHAPE
통해 클라이언트로 전송되기 전에, 서버에서 실행 CONSOLE.LOG :
{ data:
{ __typename: 'Mutation',
createAPPT:
{ id: '76',
originatingUserID: 'DsmkoaYPeAumREsqC',
apptWithUserID: '9W95z8A7Y6i34buk7',
apptDateTime: '2016-12-24T02:48:50.000Z',
apptTitle: 'Appointment with Benedict Sama',
apptNotes: 'asdf',
createdAt: Fri Dec 23 2016 10:49:12 GMT-0800 (PST),
updatedAt: Fri Dec 23 2016 10:49:12 GMT-0800 (PST),
UserData: [Object],
__typename: 'Appts'
}
}
}
방법 IT가 다시 돌아올 때 크롬 도구 도구가 눈에 띈다. RESOLVER의 클라이언트
mutationResult: Object
data: Object
createAPPT: Object
__typename: "Appts"
apptDateTime: null
apptNotes: null
apptTitle: null
apptWithUserID: null
originatingUserID: null
__proto__: Object
__proto__: Object
__proto__: Object
최종 THEN
BLOCK은
.then(apptWithJoinedData => {
//package up the results in the way that the client is expecting
const apptDataValues = apptWithJoinedData[0].dataValues;
apptDataValues.__typename = "Appts";
var serverResponse = {};
serverResponse.data = {};
serverResponse.data.__typename = 'Mutation';
serverResponse.data.createAPPT = apptDataValues;
// publish subscription notification
debugger;
console.log(serverResponse);
pubsub.publish('APPTAdded', serverResponse);
return serverResponse;
})
는 누군가가 서버 응답의 형태 뭐가 잘못 보는 방향으로 날 포인트?