Coder Social home page Coder Social logo

rxgql-java's Introduction

Just a quick example showing GraphQL Json structures being parsed into JsonObjects from a raw GraphQL request made by Retrofit and handled via RxJava.

The main question around the use of RxJava at the data layer here is why you wouldn't just use the built-in asynchronous request features of Retrofit2 directly. RxJava is better suited for performing operations on multiple streams of data making the extra boilerplate worth it for those cases.

With GraphQL, you're usually going to get the entire data structure in one shot. The majority of the work there is to map the fields to the views.

You could go really quick and dirty and just parse out JsonObjects from the responses and map the fields directly to the view, or you could use the Gson converter and supply types to be mapped-to before sending off to the view.

Either way, the schema is the source of truth and if it changes the models/bindings/queries have to as well. Since we're writing GQL queries directly in as strings, there's not a lot of boilerplate necessary to get up and running.

The majority of the work on the receiving end would really be the field mapping in almost any scenario. Doing stream work on the resulting data sets may be necessary in some cases for the future, but luckily that's an easy thing to just plug in.

Usage

gradle run

Watch terminal output for stringified JSON object containing Account #1 from the Waldo GraphQL API.

rxgql-java's People

Contributors

txbm avatar

Watchers

 avatar James Cloos avatar  avatar SS avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.