https://github.com/mdm317/mdm/tree/main/graphql-test

codegen

apollo hook 을 이용할때 codegen 으로 apollo hook 작성

codegen 으로 타입도 알 수 있음

사용한 설정코드 https://github.com/mdm317/mdm/blob/main/graphql-test/codegen.ts

mutation

update 로 쿼리 결과를 업데이트 할 수있음

문서 : https://www.apollographql.com/docs/react/data/mutations/#the-update-function

예제 : https://github.com/mdm317/mdm/blob/8a04ba3a8a44e8f0c43ce69973ae3ab69c4215b3/graphql-test/src/component/BoxList.tsx#L37

normalization

  1. 객체를 분리
  2. __typename : id 로 cache 만듬
  3. reference 로 참조 되게 만듬

normalization 을 이용하면 mutation 의 update 를 안쓰고도 query 결과를 업데이트 할 수 있음

https://www.apollographql.com/docs/react/caching/overview#data-normalization

devtools