{"id":15192360,"url":"https://github.com/florent37/android-okgraphql","last_synced_at":"2025-10-02T07:30:39.610Z","repository":{"id":91120100,"uuid":"96875964","full_name":"florent37/Android-OkGraphQl","owner":"florent37","description":"Reactive GraphQl client for Android","archived":true,"fork":false,"pushed_at":"2020-07-02T11:49:33.000Z","size":182,"stargazers_count":64,"open_issues_count":4,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-21T12:35:59.240Z","etag":null,"topics":["android","api","graphql","graphql-client","http","java","okhttp","reactive","rx","rxjava"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/florent37.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-11T09:29:06.000Z","updated_at":"2023-01-28T03:18:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"a72add5c-815c-4e50-a07b-c186ffec3f85","html_url":"https://github.com/florent37/Android-OkGraphQl","commit_stats":{"total_commits":45,"total_committers":3,"mean_commits":15.0,"dds":0.4444444444444444,"last_synced_commit":"aa2ceb7daf3fa24c8edb3307a16b7d2fe0647f91"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/florent37/Android-OkGraphQl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FAndroid-OkGraphQl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FAndroid-OkGraphQl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FAndroid-OkGraphQl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FAndroid-OkGraphQl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/florent37","download_url":"https://codeload.github.com/florent37/Android-OkGraphQl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florent37%2FAndroid-OkGraphQl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277974403,"owners_count":25908396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-02T02:00:08.890Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","api","graphql","graphql-client","http","java","okhttp","reactive","rx","rxjava"],"created_at":"2024-09-27T21:22:37.219Z","updated_at":"2025-10-02T07:30:39.296Z","avatar_url":"https://github.com/florent37.png","language":"Java","readme":"GraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data. GraphQL isn't tied to any specific database or storage engine and is instead backed by your existing code and data.\nA GraphQL service is created by defining types and fields on those types, then providing functions for each field on each type.\n\nLearn more at : http://graphql.org/learn/\n\nOkGraphQl is an Android client implementation, thinked to be easy to use, fluent, and completely modular\n\n\u003ca href=\"https://goo.gl/WXW8Dc\"\u003e\n  \u003cimg alt=\"Android app on Google Play\" src=\"https://developer.android.com/images/brand/en_app_rgb_wo_45.png\" /\u003e\n\u003c/a\u003e\n\n\n# Download\n\n\u003ca href='https://ko-fi.com/A160LCC' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n\nIn your module \n\n[![Download](https://api.bintray.com/packages/florent37/maven/OkGraphQl/images/download.svg)](https://bintray.com/florent37/maven/OkGraphQl/_latestVersion)\n```groovy\ncompile 'com.github.florent37:okgraphql:(last version)'\n\n//dependencies\ncompile 'io.reactivex.rxjava2:rxjava:2.1.9'\ncompile 'com.squareup.okhttp3:okhttp:3.9.1'\ncompile 'com.google.code.gson:gson:2.8.2'\ncompile 'com.github.florent37:android-nosql:1.0.0'\n```\n\n# Creation\n\nFirst, initialize you OkGraphQl client with\n- The GraphQl sever url\n- An OkHttpClient (optional)\n- A converter (optional)\n\n```java\nOkGraphql okGraphql = new OkGraphql.Builder()\n                .okClient(okHttpClient)\n                .baseUrl(\"http://192.168.1.16:8888/graphql\")\n                .converter(new GsonConverter(new Gson()))\n                .build();\n```\n\n# Usage\n\n**Please note that following examples have been tested on the StarWars GraphQl server : https://github.com/apollographql/starwars-server**\n\nCreate your GraphQl query with `query(string)`, \nthen execute with `enqueue(SuccessCallback, ErrorCallback)`\n\nBy default the success response is the Json (as String)\n\n```java\nokGraphql\n        .query(\"{\" +\n                \"  hero {\" +\n                \"    name\" +\n                \"  }\" +\n                \"}\"\n        )\n        .enqueue(responseString -\u003e {\n            //play with your responseString\n        }, error -\u003e {\n            //display the error\n        });\n```\n\nYou can also inflate a POJO with the returned Json using `.cast(CLASS)`\nThis will use the `converter` assigned to your OkGraphQl\n\n```java\nclass Character {\n     String name;\n}\n   \nclass StarWarsResponse {\n   Character hero;  \n}\n\nokGraphql\n        .query(\"{\" +\n                \"  hero {\" +\n                \"    name\" +\n                \"  }\" +\n                \"}\"\n        )\n        \n        .cast(StarWarsResponse.class) //will automatically cast the data json to\n\n        .enqueue(response -\u003e {\n            //play with your StarWarsResponse\n        }, error -\u003e {\n            //display the error\n        });\n```\n\n# RxJava !\n\nYou can also use RxJava methods to your query using `.toSingle()`\n\n```java\nokGraphql\n         .query(\n                 \"Hero($episode: Episode, $withFriends: Boolean!) {\" +\n                         \"  hero(episode: $episode) {\" +\n                         \"    name\" +\n                         \"    friends @include(if: $withFriends) {\" +\n                         \"      name\" +\n                         \"    }\" +\n                         \"  }\"\n         )\n\n         .variable(\"episode\", \"JEDI\")\n         .variable(\"withFriends\", false)\n\n         .cast(StarWarsResponse.class) //will automatically cast the data json to\n         \n         .toSingle()\n         .observeOn(AndroidSchedulers.mainThread())\n         .subscribe(\n                 data -\u003e textView.setText(data.toString()),\n                 throwable -\u003e textView.setText(throwable.getLocalizedMessage())\n         );\n```\n\n# Query Builder\n\nUse Fields Builders instead of Strings to create dynamically your queries\n\n```java\nokGraphql\n\n      .query(newField()\n              .field(newField(\"human\").argument(\"id: \\\"1000\\\"\")\n                      .field(\"name\")\n                      .field(\"height\")\n              )\n      )\n      \n      ...\n```\n\nThis example will generate the query :\n\n```\n{\n  human(id: \"1000\") {\n    name\n    height\n  }\n}\n```\n\n# Mutations\n\nMutations are easy to execute with OkGraphQl\n\n```java\n okGraphql\n          .mutation(\"CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) {\" +\n                  \"  createReview(episode: $ep, review: $review) {\" +\n                  \"    stars\" +\n                  \"    commentary\" +\n                  \"  }\" +\n                  \"}\")\n          .variable(\"ep\", \"JEDI\")\n          .variable(\"review\", \"{ \\\"stars\\\": 5, \\\"commentary\\\": \\\"This is a great movie!\\\"\")\n          .enqueue(responseString -\u003e {\n              text1.setText(responseString);\n          }, error -\u003e {\n              text1.setText(error.getLocalizedMessage());\n          });\n```\n\n# Fragments \n\nUse `.fragment(code)` to append a fragment on your request\n\n```java\nokGraphql\n\n                .body(\"{\" +\n                        \"  leftComparison: hero(episode: EMPIRE) {\" +\n                        \"    ...comparisonFields\" +\n                        \"  }\" +\n                        \"  rightComparison: hero(episode: JEDI) {\" +\n                        \"    ...comparisonFields\" +\n                        \"  }\" +\n                        \"}\"\n                )\n\n                .fragment(\"comparisonFields on Character {\" +\n                        \"  name\" +\n                        \"  appearsIn\" +\n                        \"  friends {\" +\n                        \"    name\" +\n                        \"  }\" +\n                        \"}\")\n\n                .enqueue(responseString -\u003e {\n                    query_hero_enqueue.setText(responseString);\n                }, error -\u003e {\n                    query_hero_enqueue.setText(error.getLocalizedMessage());\n                });\n```\n\n# Cache\n\n//TODO will use https://github.com/florent37/Android-NoSql\n\n# Credits\n\nAuthor: Florent Champigny \n\nFiches Plateau Moto : [https://www.fiches-plateau-moto.fr/](https://www.fiches-plateau-moto.fr/)\n\n\u003ca href=\"https://goo.gl/WXW8Dc\"\u003e\n  \u003cimg alt=\"Android app on Google Play\" src=\"https://developer.android.com/images/brand/en_app_rgb_wo_45.png\" /\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://plus.google.com/+florentchampigny\"\u003e\n  \u003cimg alt=\"Follow me on Google+\"\n       src=\"https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/gplus.png\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://twitter.com/florent_champ\"\u003e\n  \u003cimg alt=\"Follow me on Twitter\"\n       src=\"https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/twitter.png\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.linkedin.com/in/florentchampigny\"\u003e\n  \u003cimg alt=\"Follow me on LinkedIn\"\n       src=\"https://raw.githubusercontent.com/florent37/DaVinci/master/mobile/src/main/res/drawable-hdpi/linkedin.png\" /\u003e\n\u003c/a\u003e\n\n\nLicense\n--------\n\n    Copyright 2016 florent37, Inc.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","funding_links":["https://ko-fi.com/A160LCC'"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorent37%2Fandroid-okgraphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflorent37%2Fandroid-okgraphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorent37%2Fandroid-okgraphql/lists"}