nayaread
HomeFavouritesTopicsSources
HomeFavouritesTopicsSources
NayaRead links to original engineering blogs. All copyright belongs to the respective authors.
Shopify Engineering·Jan 22, 2021·13 min read51

Using GraphQL for High-Performing Mobile Applications - Shopify

GraphQL is the syntax that describes data that a client asks from a server. The client, in this case, is a mobile application. GraphQL is usually compared with REST API, a common syntax that most mobile application developers use. We will share how GraphQL can solve some of the pain points of REST API in mobile application development and discuss tips and best practices that we learned at Shopify by using GraphQL in our mobile applications. Why Use GraphQL? A mobile application generally has four basic layers in the codebase: Network layer: defines the connection and the server to connect to send/receive data. Data model layer: translates data coming from the network layer to understandable data for local app models. View models layer: translates data models to understandable models for the user interface. User interface layer: presents/receives data to/from the user. A network layer and data model layer are needed for an app to talk to a server and translate that information to view layers. GraphQL can fit into these two layers and base a data graph layer and solve most of the pain points mobile developers used to have when using REST APIs. One of the pain points when using REST APIs is that the data coming from the server should be mapped many times to different object types in order to be presented on the screen or vice versa from input in the screen to be sent to the server. Simpler apps might have fewer of these mappings depending on if the app has a local database to store data or if the app is online only. But mobile apps surely have the mapping to convert the JSON data coming from an API to a class object (for example, Swift objects ). When working with REST endpoints these mappings are basically matching statically typed code with the unstructured JSON responses. In other words, mobile developers are asked to hard code the type of a field and

BackendMobile
Read original on shopify.engineering

Discussion around the web

  • Hacker News3 · 0 💬

Score breakdown

  • Technical depth81
  • Practical value60
  • Originality60
  • Writing quality100
  • Source reputation0
  • Recency0
  • External engagement6
  • On-site engagement0

NayaRead shows a summary and links to the original article. The full article is hosted on shopify.engineering.

More like this

Shopify Engineering

Solving the N+1 Problem for GraphQL through Batching - Shopify

Apr 24, 2018·7 min read
Shopify Engineering

Understanding GraphQL for Beginners–Part One - Shopify

Jul 2, 2021·8 min read
Shopify Engineering

Unifying Our GraphQL Design Patterns and Best Practices with Tutorials - Shopify

Feb 13, 2019·5 min read
Shopify Engineering

Querying Strategies for GraphQL Clients - Shopify

Jun 15, 2021·10 min read