Skip to content

Latest commit

 

History

History
50 lines (44 loc) · 833 Bytes

README.md

File metadata and controls

50 lines (44 loc) · 833 Bytes

GraphQL-Sample

TEST 서버: https://rickandmortyapi.com/graphql/

Install Apollo

brew install apollo-cli

Download schema.json

apollo schema:download --endpoint=서버주소 schema.json

Create ~.graphql

예시)

query FeedResult {
  characters {
    results {
      name
      species
      gender
      image
    }
  }
}

Request

Callback

apolloClient.query(TestQuery())
    .enqueue(object : ApolloCall.Callback<TestQuery.Data>() {
        override fun onResponse(response: Response<TestQuery.Data>) {
            ...
        }

        override fun onFailure(e: ApolloException) {
            ...
        }
    })

Rx

apolloClient.rxQuery(TestQuery())
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(...)