sync_surveys

Retrieve a list of surveys that have changed.

Arguments

content_hashes ([String!]!)

An array of content hashes for surveys the client has previously retrieved. The server will return surveys whose content hashes do not match the client's content hashes.

field_sentera_id (ID!)

The ID of the field containing the surveys to be synced.

Return fields

deleted ([SyncItem!]!)

Items that have been deleted.

failed ([SyncError!])

A list describing errors that occurred during the syncing process.

remaining_count (Int!)

The number of items remaining to be synced.

upserted ([SyncItem!]!)

Items that have been inserted or updated.

Examples

Sync Surveys for a field

This query is used by a client to sync surveys for a specific field with surveys stored on the server. This query will return up to the first 2,000 surveys in a field that are different from the surveys held by the client. To retrieve the remaining surveys, a client should call this query repeatedly, passing in the full set of content hashes for surveys it holds, until no more surveys are returned, or the remaining count returned is 0.

Try this example in GraphiQL
query SyncFieldSuveys {       
  sync_surveys(
  field_sentera_id: "4zjxgyd_AS_2oshAcme_CV_deve_87574b995_220203_142642",
  content_hashes: [
    "xdNDk/aet07YA1pi"
    "/h9Kp8h1wLAR77g6"
    "pZCIzimW+sJQ1tPP"
  ]
  ) {
  remaining_count
  upserted {
    sentera_id
    content_hash
    created_at
    created_by {
      sentera_id
    }
    ... on Survey {
      name
      color
      images {
        total_count
        results {
          filename
        }
      }
    }
  }
  deleted {
    sentera_id
    content_hash
  }
  }
}

{
  "data": {
  "sync_surveys": {
    "remaining_count": 0,
    "upserted": [
      {
        "sentera_id": "7tbyhij_CO_2oshAcme_CV_deve_87574b995_220203_142643",
        "content_hash": "2fbAlKNi1vWrEEau",
        "created_at": "2022-02-03T20:26:43Z",
        "created_by": {
          "sentera_id": "h541p4w_US_2oshAcme_CV_deve_87574b995_220203_142641"
        },
        "name": "02-03-2022",
        "color": "#4C5E1D",
        "images": {
          "total_count": 1,
          "results": [
            {
              "filename": "image1.jpg"
            }
          ]
        }
      }
    ],
    "deleted": [
      {
        "sentera_id": "7tbyhij_CO_2oshAcme_CV_deve_87574b995_220203_142644",
        "content_hash": "2fbAlKNi1vWrEEaV"
      }
    ]
  }
  }
}