Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

GraphQL for Managing Marionette’s APIs

Being a GraphQL is query language for API’s, GraphQL gives Marionette full control over API data we want to fetch from the server and full control over how we fetch this data. Instead . It empowers Marionette with the ultimate control of defining the exact API data of interest and how to fetch this data from the server, instead of fetching full representations of resources. For example, GraphQL allows us to fetch one or more properties of a resource, such as the order, or just the status of an order. With GraphQL, Marionette models the relationship between different objects and retrieves defined individual properties from various objects individually from multiple resources and not the full scope of data associated with those resources.

This allows Marionette to model the relationship between multiple (or single) resources and retrieve just the the defined individual properties from multiple (or single) resources, while achieving this in a single request from the server. In contrast, with other types of APIs, such as RESTcomparison with REST APIs, you get a full list of details properties for each objectresource. Considering the important of control of how performance and business importance of minimizing the amount of the data is fetched from the server, GraphQL is a clear choice for Marionette, but let’s take a deeper another look.

For example: Trading service owns data about (a) trades, (b) each side of the order and , plus (c) a rich list of properties that describe the extensive details of any one particular trade or for a group of associated trades. However, when the end-user requests to see a list of information applicable to the trade(s), in their trading history for example, Marionette operator will not display the extensive details of the trade to the user. It is best practice in their application, there’s no reason to display or fetch the extensive list of details related to each individual trade. Most logical practice is to only fetch the data they that will relay be relayed to the Frontend UI and only display the key data interesting to this user. Further, Marionette operator will often fetch data from various trading services to relay data visible to the end-user is requesting to see on the Front-end. . Further, GraphQL offers the the ability to traverse the relationships between trades, orders, and other objects owned by the trading service and do so with minimal server requests.

...