Skip to content

Sync changesets in the background instead of in ApplyCampaign

Administrator requested to merge mrn/sync-background into main

Created by: mrnugget

This changes the ApplyCampaign mutation so that it doesn't sync imported changesets in the request path. Instead it flags the changesets as unsynced and enqueues them to be picked up the reconciler. The reconciler then syncs them.

Instead of a enum I simply used a boolean flag, which gives us a handy default value and makes the migration easy.

Since changesets can now exist in the DB without having any external data, I had to loosen the constraints in the API a bit: Title and Body are now nullable (because we don't know what the title/body are until we've synced the changeset, of course).

The downside is that a freshly added but unsynced changeset looks like this in the UI:

screenshot_2020-08-25_11 14 50@2x

It's cool that the processing works already, but the parentheses around the external ID look a bit weird...

@eseliger should we expose "Unsynced" in the GraphQL API so we can check for that? Or something like "SyncStatus"? Although, again, an enum might be overblown.

Merge request reports

Loading