Skip to content

A simple example to introduce beginners to GraphQL using the Apollo SDK

Notifications You must be signed in to change notification settings

ollyc2015/GraphQLExample

Repository files navigation

GraphQL Example

A simple example of consuming data using GraphQL

Background

The data is obtained using the Rick & Morty API

Motivation

I was introduced to the topic of GraphQL, but I hadn't seen any examples. When I started to take a look, I realised a lot of the examples I had come across were deprecated, so I thought I would read the docs, build something to teach myself and hopefully, help others.  

Steps to reproduce

This project uses the Apollo SDK - first, go to the Apollo site to check out how to add Apollo-Android to your Project.

In regards to Downloading a schema.json file, the Apollo documentation states to run the following command: ./gradlew :module:downloadApolloSchema -Pcom.apollographql.apollo.endpoint=https://rickandmortyapi.com/graphql/ -Pcom.apollographql.apollo.schema=src/main/graphql/com/example/schema.json

If you're on a windows machine make sure you use .\ at the beginining of the above commond, rather than ./

Please note, in the above command, you're putting your schema.json in the directory in the above command, so make sure it exists!

Design

  • GraphQL
  • MVVM
  • Koin
  • Fragment
  • RecyclerView
  • CardView
  • Glide

Additional Notes

If you want to look at the GraphQL structure in this project, make sure you're in the project view. Then go to: GraphQLExample\app\src\main\graphql\com\example

From there you can see the schema.json, .graphqlconfig and results.graphql. The results.graphql contains the query used to get the relevant data back that we use to present to the user.

About

A simple example to introduce beginners to GraphQL using the Apollo SDK

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages