We know how to read data from a single record/object.
Now, let’s see how to read data from multiple records/objects.
- The
find
function returns the records matching the provided arcql filter.
find(type: HypiMutationType!, arcql: String!, first: Int,after: String,last: Int,before: String, includeTrashed: Boolean): HypiFilterConnection!
- In this post, we will just use two parameters from the
find
function to retrieve multiple records; type and arcql. We will see the use of other parameters in a separate post. - We will use the
*
value for the arcql filter. This returns all the records/objects of the specified data type. - We will use the same ReadObject data type from the previous post and populate it with data.
type ReadObject {
field1: String
field2: Int
}
Sample Query
{
find(type: ReadObject, arcql: "*") {
edges {
cursor
node {
... on ReadObject {
hypi {
id
created
}
field1
field2
}
}
}
}
}
#result
{
"data": {
"find": {
"edges": [
{
"cursor": "01FGV16MCMRRKCYQHTE95SVYXC",
"node": {
"hypi": {
"id": "01FGV16MCMRRKCYQHTE95SVYXC",
"created": "2021-09-30T09:40:08Z"
},
"field1": "Go serverless with Hypi's low code platform",
"field2": 1
}
},
{
"cursor": "01FGXSXWZDD62D68EJSD186NTP",
"node": {
"hypi": {
"id": "01FGXSXWZDD62D68EJSD186NTP",
"created": "2021-10-01T11:30:45Z"
},
"field1": "Multiply your development velocity with Hypi",
"field2": 2
}
},
{
"cursor": "01FGXSXWZDRWZE2X9ZGH7Y7103",
"node": {
"hypi": {
"id": "01FGXSXWZDRWZE2X9ZGH7Y7103",
"created": "2021-10-01T11:30:45Z"
},
"field1": "Instant backend support with Hypi",
"field2": 3
}
}
]
}
}
}
Output
find
query returns only the data from the fields you define within the query. In the above query, data from the hypi object, field1 and field2 have been returned.
Data from all the objects of ReadObject data type gets returned.
Query with Variables
query GetMultipleRecord($type: HypiMutationType!, $arcql: String!) {
find(type: $type, arcql: $arcql) {
edges {
cursor
node {
... on ReadObject {
hypi {
id
created
}
field1
field2
}
}
}
}
}
# result
{
"type": "ReadObject",
"arcql": "*"
}
Please note query variables has the form of JSON.
Check the POSTMAN collection for the find
requests in different programming languages! Click </>
and choose the programming language of your choice.
Don’t forget to insert your own Authorization key and Hypi Domain under Headers to test the results!