upsert_fields

Upsert (create and/or update) one or more fields.

Input fields

fields ([FieldImport!]!)

An array of FieldImport objects to upsert. The limit is 100 fields.

organization_sentera_id (ID!)

The ID of the Organization that these Fields will be upserted into.

Return fields

failed ([UpsertError!]!)

Detailed error information for UpsertItems that failed to upsert.

succeeded ([UpsertItem!]!)

UpsertItems that have been successfully upserted.

Examples

Upsert Fields

Upserts an array of fields

Try this example in GraphiQL
mutation UpsertFieldsExample {
  upsert_fields(
    organization_sentera_id: "qfwqfiy_OR_8brhbkSentera_CV_deve_661a71a38_231214_151711"
    fields: [
      {
        name: "New Tiny Triangle",
        latitude: 45.0946385,
        longitude: -91.5948085,
        boundary:  {
          type: "FeatureCollection",
          features: [
            {
              type: "Feature",
              properties: {},
              geometry: {
                type: "MultiPolygon",
                coordinates: [
                  [
                    [
                      [ -91.5948085, 45.0946385 ],
                      [ -91.5885835, 45.0947915 ],
                      [ -91.5893452, 45.0933998 ],
                      [ -91.5948085, 45.0946385 ]
                    ]
                  ]
                ]
              }
            }
          ]
        }
      },
      {
        name: "Invalid Field",
        longitude: 45.0
        latitude: 1111111111111
      }
    ]
  ) {
    succeeded {
      sentera_id
      ... on Field {
        name
        acres
      }
    }
    failed {
      index
      item {
        sentera_id
        ... on Field {
          name
        }
      }
      attributes {
        attribute
        key
        details
        message
      }
    }
  }
}

{
  "data": {
    "upsert_fields": {
      "succeeded": [
        {
          "sentera_id": "jzt2lzz_AS_8brhbkSentera_CV_deve_a66dedf98_200410_121407",
          "name": "New Tiny Triangle",
          "acres": 9.23793
        }
      ],
      "failed": [
        {
          "index": 1,
          "item": {
            "sentera_id": "tdfrl78_AS_8brhbkSentera_CV_deve_a66dedf98_200410_121407",
            "name": "Invalid Field"
          },
          "attributes": [
            {
              "attribute": "latitude",
              "key": "less_than_or_equal_to",
              "details": {
                "value": "1111111111111.0",
                "count": 90
              },
              "message": "must be less than or equal to 90"
            },
            {
              "attribute": "boundary",
              "key": "blank",
              "details": {},
              "message": "has invalid coordinates"
            },
            {
              "attribute": "boundary",
              "key": "invalid_multipolygon",
              "details": {},
              "message": "is not a MultiPolygon"
            }
          ]
        }
      ]
    }
  }
}