Skip to main content

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

GraphQL errors

HTTP success does not guarantee operation success. Check the top-level errors array before reading data.