Data Gateway
The Data service discovers project schemas, then uses each schema's server-provided GraphQL names to query and mutate records.
List schemas
GET /data/v4/schemas?ProjectKey={projectKey}&PageNo=1&PageSize=100
curl --get 'https://api.seliseblocks.com/data/v4/schemas' \
-H 'x-blocks-key: YOUR_PROJECT_KEY' \
--data-urlencode 'ProjectKey=YOUR_PROJECT_KEY' \
--data-urlencode 'PageNo=1' \
--data-urlencode 'PageSize=100'
Schemas are found in data.items (or items). Use querySchema, schemaName, fields, and mutationSchemas from the response. Do not derive operation names when the API supplies them.
Query records
POST /data/v4/gateway
{
"query": "query { getClients(where: {}, order: [], paging: { pageNo: 1, pageSize: 20 }) { items { ItemId Name Email } totalCount pageNo pageSize totalPages hasNextPage hasPreviousPage } }"
}
Only scalar fields may be selected without a nested selection. The example includes ItemId, de-duplicates fields case-insensitively, and omits object/relation fields.
Insert a record
POST /data/v4/gateway
{
"query": "mutation($input: ClientInsertInput!){ insertClient(input:$input){ acknowledged itemId totalImpactedData message } }",
"variables": {
"input": {
"Name": "Ada Lovelace",
"Email": "ada@example.com"
}
}
}
The input type is {schemaName}InsertInput. For the mutation field, the app uses the first name in mutationSchemas beginning with insert, falling back to insert{schemaName}.
Geospatial queries
A schema field of type GeoJson stores an RFC 7946 geometry (Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, or GeometryCollection) as a plain object. Coordinates are [longitude, latitude]. Feature/FeatureCollection wrappers are rejected. Each GeoJson field gets an automatic 2dsphere index, listed under the schema's system indexes.
Filter a GeoJson field with eq, neq, near, within, or intersects:
{
"query": "query { getStores(where: { Location: { near: { geometry: { type: \"Point\", coordinates: [90.4125, 23.8103] }, maxDistanceMeters: 5000 } } }, paging: { pageNo: 1, pageSize: 20 }) { items { ItemId Name Location } totalCount } }"
}
| Operator | Operand | Matches |
|---|---|---|
near | { geometry: Point, maxDistanceMeters, minDistanceMeters? } | Within maxDistanceMeters of the point (and beyond minDistanceMeters when given). Both must be positive, and min must be less than max. Results are not sorted by distance. |
within | { geometry: Polygon | MultiPolygon } | Entirely inside the area. |
intersects | { geometry: <any geometry> } | Touching or overlapping the geometry. |
An invalid reference geometry or distance fails the query with a GraphQL errors entry naming the operator.
GraphQL errors
HTTP success does not guarantee operation success. Check the top-level errors array before reading data.