{ getLocation(ip: “172.59.226.170") { country { names { en } geoname_id iso_code } location { latitude longitude } } } "For the available data, return the English name for the country"
{ getLocation(ip: “172.59.226.170") { country { names { en } geoname_id iso_code } location { latitude longitude } } } "For the available data, return the latitude and the longitude from the geolocation info"
MORE ABOUT OPERATIONS • Data payload will mirror the type hierarchy defined on schema • All data types for queries/mutations must be defined on schema • Operation can accept parameters and/or variables • We can form better, readable blocks for operations using aliases and fragments • Etc
CLIENT INTENT REST + HTTP GraphQL + HTTP GraphQL Operation READ RESOURCE GET POST QUERY CREATE RESOURCE POST POST MUTATION UPDATE RESOURCE PUT POST MUTATION REMOVE RESOURCE DELETE POST MUTATION
APOLLO + ANDROID • Full-featured tooling + library, inspired by Retrofit • Custom OkHttpClient support • Code generation for queries / mutations : request models and payloads • Cache-ready client, including L0, L1 e L2 support • RxJava support • Etc
query LocationQuery ($ip: String!) { getLocation(ip: $ip) { country { names { en } geoname_id iso_code } location { latitude longitude } } } Generated class member To-be-generated class name Operation Type
FINAL REMARKS • GraphQL is just a spec • GraphQL aims to solve some of well know issues from REST • GraphQL is mobile friendly, but it brings its own set of challenges (for free, rs)
FINAL REMARKS • GraphQL is just a spec • GraphQL aims to solve some of well know issues from REST • GraphQL is mobile friendly, but it brings its own set of challenges (for free, rs) • Apollo is an OSS effort for easy integration of GraphQL clients, and it has a full-featured Android native API
REFERENCES Oficial GraphQL Website http://graphql.org How to GraphQL https://www.howtographql.com Github Training on GraphQL https://services.github.com/on-demand/graphql Apollo Client for Android - Documentation http://dev.apollodata.com/android