Apollo Cache 업데이트

roglog·2021년 4월 2일
0

캐시를 업데이트 하는 방법

  1. mutation 후 query를 refetch함
  2. cache를 직접 update함

Cache Update

  • Ex)
  import {useApolloClient} from “@apollo/client”;

  const client = useApolloClient()

  client.writeFragment({
      id: `User:${data.id}`,
      fragment: gql`
          fragment VerifiedUser on User {
              email
          }
      `,
      data: {
          email: newEmail
      },
  });
profile
Full Stack Developer 📚

0개의 댓글