samedi 25 mai 2019

Way to segregate data with components

My react.js components get data from separately hosted graphQL service. Currently, the components are tightly coupled with service's schemas. For ex: component need item-name and read it from response.items.item[0].name.

Now, I have to change the source service and schema for this new service is quite different. For ex: item-name is now present in response.products.product[0].item.name.

I want to have some confidence with this service migration. Ex: item-name is same and present with new source service.

I wish to have this data source migration to be testable at data level rather than leaking the schemas to component level. Two questions -

  • Is there any general pattern to hold source data at one place and use wrappers in components?
  • How to test it side-by-side with old versus new data services?

Aucun commentaire:

Enregistrer un commentaire