Querying Your Databases

Last updated on June 26, 2024.

This article guides you in fetching and filtering data from your database.

Fetching data from a field with GraphQL according to type

Database fields depend on their parent database table objects and are accessible in the query after mapping the field's name with the query attribute name. You can do that with the family of fields defined in our GraphQL PropertiesInterface documentation. for example:

Observe lines 9-10 in the above example and take note of the following:

  • :

    Fetches the database field labeled 'name' and returns the value as a String. This is then mapped to the 'query_name' query attribute name. The data can then be rendered on a page or used on an API endpoint.

  • :

    Fetches the database field labeled 'age' and returns the value as an Integer. The value is then mapped to the 'query_age' query attribute name. The data can then be rendered on a page or used on an API endpoint.

  • :

    Fetches the database field labeled 'enabled' and returns the value as a Boolean. The value is then mapped to the 'query_enabled' query attribute name which can then be rendered on a page or used on an API endpoint.

Filtering database fields with GraphQL

You can filter GraphQL results based on an object's database field values. All options are defined in GraphQL PropertyFilterInput. Some examples:

value - matches the value of a given field

not_value - does not match the value of the given field.

value_int - matches the value of the given field.

value_float - matches the value of the given field.

value_boolean - matches the value of the given field.

value_in - matches any value of the provided array.

not_value_in - does not match any value of the provided array.

range - available options for the range are: , , , and :

uses ISO 8601 date-time formats, for example:

exists

Please note that the above examples are only valid for database fields defined in Table. Please refer to the GraphQL schema in to filter fields defined on different parents - parents that do not fall under Tables.

Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.