◦ Type safe ◦ Send a single GraphQL query to API and get all the data your app needs ▪ No overfetch ▪ No underfetch • GraphQL is modeling the business domain in a graph structure ◦ Fetching resources: query ◦ Updating resources: mutation
to call GraphQL API • Manage both local and remote data with GraphQL ◦ Declarative data fetching ◦ Intelligent caching • Designed for modern React ◦ Apollo Client library provides hooks API(useQuery, useMutation)
result in a graph structure ◦ Entities in the graph are identified by id and __typename and automatically normalized ◦ Programmers no need to manage the cache themselves • Apollo Client updates query result automatically when local cache updated by data from server • You can use the query result of Apollo Client as a Single Source of Truth
• GraphQL is a type safe query language for APIs • Apollo Client is a comprehensive state management library for React • Apollo + React enable Single Source of Truth architecture
• GraphQL is a type safe query language for APIs • Apollo Client is a comprehensive state management library for React • Apollo + React enable Single Source of Truth architecture → We can do the same things with Apollo + Jetpack Compose
create hooks-like composable function by wrapping Apollo Kotlin Client • Implement extension functions to Apollo Kotlin Client with reference to the JavaScript Apollo Client API React Hooks Composable Function useQuery useMutation watch mutation query mutation
string ◦ variables • Results ◦ data(GraphQL query result) ◦ loading(If true, the query is still in flight and results have not yet been returned) ◦ error(Either an array of graphQLErrors or a single networkError) ◦ refetch(Re-execute query function)
string) • Results ◦ mutateFunction(A function to trigger the mutation) ◦ data(Returned from mutation) ◦ loading(If true, the mutation is currently in flight) ◦ error(Either an array of graphQLErrors or a single networkError)
not only to call GraphQL API ◦ Apollo Client enables Single Source of Truth architecture ◦ Apollo Client + React enables declarative data fetching ◦ Apollo + React make easy to state management and API calls in frontend development ◦ But Apollo Kotlin not yet provide composable functions like Apollo Client hooks API • We can create composable function like Apollo Client hooks API by wrapping Apollo Kotlin ◦ We can enable Single Source of Truth architecture and declarative data fetching in Jetpack Compose ◦ Apollo + Jetpack Compose make easy to state management and API calls in Android development