스키마는
Apollo Cache
Apollo Link
fetchPolicy
Query Component
Persisted Query Link
Batch HTTP Link
schemaLink라는게 있다.
// undefined일 수 있는 객체를 참조할 경우 exception 대신 undefiend가 나오게 할 수 있다.
function safe(f) {
try {
return f()
} catch {
return undefined
}
}
페이지네이션 구현 트릭
키워드 알려드릴께요!
Redux나 MobX를 대체해 로컬에서 글로벌한 상태관리를 Apollo로 대체 할 수 있나요?
MobX 그래프큐엘을 보았다.보셧나요?
아폴로 구성할때 클라이언트 구성할때 쿼리방식이랑 프로파이더를 사용하는 방식 어떤 차이가 있나
스키마를 보면은 모든 스키마가 다 나오자나요 일부만 보여줄 수 있나요?
하지만 Component Composition과 RenderProps를 활용해 비동기 요청에 대해 loading, success, error를 핸들링하는 부분은 상태관리 라이브러리에 미들웨어를 적용해 처리하는 과정보다 매우 편리해 보였다.
import React from 'react'
import { Query } from 'react-apollo'
import { gql } from 'apollo-boost'
const query = gql`
query Boo($id: ID!) {
user(id: $id) {
id
name
}
}
`
const App: React.FC = () => {
return (
<Query query={query} variables={{ id: '14' }}> {({ data, loading, error }: any) => { if (loading) { return <p>LOADING..</p> } if (error) { return <p>error</p> } return <p>{data.user.name}</p> }} </Query>)
}