After setting up a connection with the playground, you can start collecting data through queries. In this article, we're looking at some examples of how to do this.
For Data API queries we will have to touch on these subjects:
Data API's query examples
Limits on the Data API
Note: Connecting through the playground will also give you an entire list of queries available. This article is meant for examples of different options.
For the examples in this article, we'll be using a Task model. Apply queries for your implementation using models of your application.
Get all tasks
Using this query, you will return an overview of all Task records, containing the properties' values as configured.
{
allTask {
results {
id
task
}
}
}
Example
Get tasks with a 'where' filter
This query will return an overview of all Task records matching the criteria in the 'where'
filter, containing the properties' values as configured.
{
allTask(where: { id : { in: [3, 4]} } ){
results {
id
task
}
}
}
Example
Get one task
Return the first Task record matching the criteria in the 'where'
filter, containing the properties' values as configured.
{
oneTask (where: { id : { eq: 3} } ) {
id
task
}
}
Example
Get tasks sorted in a specific order
A query that will return an overview of multiple Task records in an ascending or descending order of the specified property, containing the properties' values as configured. Accepts ASC
and DESC
.
{
allTask(sort: {field: id, order: DESC}) {
results {
id
}
}
}
Example
Get a task with relational data
This query will return the first Task record matching the criteria in the 'where'
filter, containing the properties' values as configured, including all configured values of a related record.
Note: Make sure the authorization on the relational data is set up properly. The (un)authenticated should be able to query the related data. Otherwise, an ‘Unauthorized’ error will be shown.
{
oneTask (id:3) {
id
task
webUser {
id
}
}
}
Example
Retrieving file properties
Return the Task records matching the criteria in the 'where'
filter, containing the properties' values as configured, including the configured file property values (name
, URL
).
query {
allArtists {
results {
name
songs {
art {
name
url
}
}
}
}
}
Limits on the Data API
To ensure smooth collaboration between our platform and your application, we have established specific restrictions on the use of the Data API for queries:
Read request rate:
for live production applications: 200 per minute,
for non-live production applications and sandboxes: 100 per minute.
Database query timeout: 5 seconds.
Maximum queries per request: 10 queries.
Maximum nesting of relations inside a query: 4 layers.
Keep these limits in mind whilst creating your application to make sure your application will run smoothly and stable. Follow the Data API rate limiter article to learn more.