GraphQL Queries
How to use queries to get data from the ObjectBox GraphQL database
Query Name
The name of a GraphQL query is similar but not equal to the corresponding database entity type:
for ObjectBox entities starting from a capital letter (e.g. TestEntity), the GraphQL query name has the first character in lowercase (testEntity);
for ObjectBox entities starting form a lowercase letter, the GraphQL query is called
query_typeName
(so, e.g. the query for testEntity isquery_testEntity
).
Query arguments
Simple query all
Get all objects of a given type by querying without any arguments.
Query by ID
To select specific objects, you can query by ID(s) by simply supplying an array to the ids
argument.
Filters
Use filters to query with more complicated query conditions. The query will only return objects matching all given conditions. Note that querying by ID is significantly more efficient, so prefer to use that if the local object IDs are known (e.g. from previous queries).
Example using a filter to find all objects with a simpleString property equlal to banana
.
Query Conditions for different property types
Each property type has its own set of query conditions. These are listed in the box below.
Properties of type Bool
only have one query condition:
eq
: equals a given bool value (true or false)
Pagination
Pagination is supported via offset
and first
arguments.
offset
- return objects starting at the given offset (0-based, e.g. 1 will skip the first object and start at the second).first
- return only the first n objects (limits the number of returned objects).
Last updated