This is a small example project that uses the Apollo Kotlin GraphQL library on Android, with Github's API.
The aim is to explore this library and GraphQL in general.
👉 https://developer.github.com/v4/guides/forming-calls/#authenticating-with-graphql
Then put it in build.properties
(follow the sample in build.properties.SAMPLE).
Either, manually: 👉 https://github.com/octokit/graphql-schema
Or using Apollo's gradle task:
./gradlew downloadGithubApolloSchemaFromIntrospection
(replace <your token>
by the token you got from Github)
There is a single activity which is a host for 4 Compose layouts:
Shows information about the "Viewer" (the currently logged-in user is called "Viewer" in the Github API):
- Login
- Name
- Total number of repos
- Info about the first 10 repos (name, description, number of stars)
Noteworthy:
- all this information is fetched with a single query (see
ViewerInfoQuery.graphql
) - use of the
@nonnull
annotation (specific to the Apollo Kotlin library), to "improve" the schema
Displays a paginated list of the viewer's repositories.
Noteworthy:
- use of a GraphQL "fragment" (see
UserRepositoryListQuery.graphql
) - how pagination works in GraphQL ("cursor")
- integration with the Android Pagination component
Use the "search" operation and demonstrate a case with heterogeneous results - either User
or Organization
(see SearchQuery.graphql
)
Demonstrates mutations and error handling (see AddCommentToIssueMutation.graphql
)
- Add comment to an issue that exists
- Add comment to an issue that doesn't exist (error case)
- GraphQL spec
- Intro to GraphQL
- Apollo Kotlin README
- Github GraphQL API doc
- Github GraphQL Explorer (More info)
- GraphQL pagination
This is PUBLIC DOMAIN.