GithubHelp home page GithubHelp logo

stagesync's Introduction

Syncing Content Between Stages

Note: This is a set of helpful utilities and scripts to sync content between multiple stages of a project. To get a better understanding of when one should or even should-not be syncing content between stages, please refer to the tutorial at Syncing Content Between Stages.

The Strategy

We'll handle our sync in a three step process. Each step is composed of a two step process. We will read (and paginate) the response from the server. We'll send each page of data as a mutation via either an upsert query or an import method which will create nodes that do not exist, and update ones that do.

Sync the Assets

Because assets touch a few external systems, we'll be syncing them first. This allows us to ensure that they are ready as we create or update our content models.

There's an inherent round-trip involved with syncing assets between the stages. The physical assets are stored in a "per-stage" bucket at our CDN. When a stage is deleted, the bucket is destroyed and the physical assets backing the image is gone. To sync across stages, we first need to check if an asset exists in our destination stage. If the asset exists, we can simply update the content. If it does not, we need to upload the asset to the correct destination bucket at the CDN, return the data, associate the new asset with the existing asset ID and then import that into our destination stage.

Sync the Models (with asset relations)

In phase two we will sync all the models themselves. In my example I have Hotels, Destinations and Reviews. I've written read queries and upsert mutations for each type. The queries are sparse for the sake of example, but you can expand them as much as you need for the data you expect to change.

In my example, I only added a Twitter handle to my hotel schema.

The reason we do this with the API is that it allows us to handle any data transformations in-flight should we need to do some data cleansing.

Connect the Relationships

The last phase is to connect all the relationships from our source stage to our destination stage once we've ensured all the nodes of our graph are present. Since this is not a data model to be changed, we'll use the import API.

Next Steps

The complete step-by-step is available over at Syncing Content Between Stages. You will need iInformation on creating system tokens, querying the management API and more which is covered in detail at the link.

stagesync's People

Contributors

motleydev 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.