Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Protocol
- 리펙토링
- combine
- Observable
- collectionview
- uitableview
- swift documentation
- ios
- tableView
- RxCocoa
- 리펙터링
- Clean Code
- 애니메이션
- 스위프트
- 클린 코드
- swiftUI
- rxswift
- HIG
- Human interface guide
- Refactoring
- UITextView
- ribs
- uiscrollview
- MVVM
- SWIFT
- map
- UICollectionView
- Xcode
- clean architecture
- 리팩토링
Archives
- Today
- Total
김종권의 iOS 앱 개발 알아가기
[iOS - swift] 2. GraphQL - Apollo 사용 개념 본문
1. GraphQL - 개념
2. GraphQL - Apollo 사용 준비
3. GraphQL - Apollo 모델 생성 (generate model)
4. GraphQL - Apollo의 request pipeline, Interceptor, token, header
5. GraphQL - Apollo의 fetch 예제 (Pagination)
Apollo 개념
- iOS에서 캐싱을 지원하고 GraphQL을 편리하게 사용할 수 있게 만들어주는 프레임워크
- 백엔드 쪽에서 정의된 schema를 가지고 xcode에서 model을 자동으로 generation 가능
Apollo 사용 준비
- installing - cocoapods 이용
- SPM, Carthage를 사용한 방법은 이곳 참고
pod 'Apollo'
모델이 Generation 되는 빌드 세팅
- API.swift 파일이 자동으로 생성되도록 세팅
- .graphql 파일을 사용하여 API 코드를 생성
- 빌드 프로세스의 일부로 코드 생성을 실행하려면 Comile source 전에 실행되는 빌드 단계가 필요
- Run Script 추가
- 컴파일 전에 실행되어야 하므로 Compile Sources 위쪽에 배치
* cocoapods의 Run Script
# Don't run this during index builds
if [ $ACTION = "indexbuild" ]; then exit 0; fi
SCRIPT_PATH="${PODS_ROOT}/Apollo/scripts"
cd "${SRCROOT}/${TARGET_NAME}"
"${SCRIPT_PATH}"/run-bundled-codegen.sh codegen:generate --target=swift --includes=./**/*.graphql --localSchemaFile="schema.json" API.swift
- Input Files와 Ouput Files 정의 - 변경된 사항이 없는 경우 중복으로 generation되지 않도록 설정
- input file: $(SRCROOT)/{TargetName}/*.graphql
- output file: $(SRCROOT)/{TargetName}/API.swift
* 전체 코드: https://github.com/JK0369/ExApollo
* 참고
https://www.apollographql.com/docs/ios/tutorial/tutorial-introduction/
'iOS framework' 카테고리의 다른 글
Comments