- Create new iOS project in Xcode
- Use Carthage to bring in Apollo as a dependancy
touch Cartfile
open Cartfile
github "apollostack/apollo-ios"
carthage update
- Link to
Apollo.framwork
- Add build script
/usr/local/bin/carthage copy-frameworks
$(SRCROOT)/Carthage/Build/iOS/Apollo.framework
- Install
apollo-codegen
npm install -g apollo-codegen
- Add codegen build phase
APOLLO_FRAMEWORK_PATH="$(eval find $FRAMEWORK_SEARCH_PATHS -name "Apollo.framework" -maxdepth 1)"
if [ -z "$APOLLO_FRAMEWORK_PATH" ]; then
echo "error: Couldn't find Apollo.framework in FRAMEWORK_SEARCH_PATHS; make sure to add the framework to your project."
exit 1
fi
cd "${SRCROOT}/${TARGET_NAME}"
$APOLLO_FRAMEWORK_PATH/check-and-run-apollo-codegen.sh generate $(find . -name '*.graphql') --schema schema.json --output API.swift
apollo-codegen download-schema https://api.github.com/graphql --output schema.json --header "Authorization: Bearer <token>"
- Build to generate
API.swift
, link to target
- Use GraphiQL to create query
query PublicRepos {
viewer {
login
repositories(first: 10, privacy: PUBLIC) {
edges {
node {
id
name
}
}
}
}
}
- Build, take a look at
API.swift