Edit Page

GraphQL types and filters

This page provides a reference of the data types enforced by the Rhize database schema, and of the filters that can apply to these types when you query, update, or delete a set of resources. For an extended guide, with examples, read Use query filters.

Note These filters are based on Rhize’s implementation of the Dgraph @search directives.

Data types

Every object in the Rhize schema has fields that are of one of the basic data types. From the other perspective, these data types define fields that compose manufacturing objects, objects defined precisely by ISA-95 and enforced by Rhize’s database schema.

Basic types

Every manufacturing object in the Rhize database is made of fields that are of one the following basic types. In official GraphQL terminology, these types are called scalar types.

  • String: A sequence of characters. For example, machine_2

  • Int: An integer number. For example, 2.

  • Float: A number that includes a fraction. For example, 2.25.

  • Boolean: A field whose value is either true or false.

  • Enum: A field whose values are restricted to a defined set. For example, versionState might be one of ACTIVE, APPROVED, FOR_REVIEW, DRAFT, or DEPRECATED

  • id: A string representing a unique object within a defined object type.

  • iid: The object’s unique address in the database. For example, 0xf9b49.

  • DateTime: A timestamp in RFC 3339 format.

  • Geo: Geometry types for geo-spatial coordinates

Object type

The preceding basic types form the building blocks for Rhize’s manufacturing object schema, with data models corresponding to ISA-95.

Each object is made of manufacturing-specific fields of one of the basic types. For example, the materialActual object has basic fields, including:

  • description, a String.
  • effectiveEnd, a DateTime

The materialActual also has complex fields describing associated manufacturing objects. For example, its fields include the array of associated MaterialLot objects, the MaterialDefinition object, and so on. All objects in the database have relationships to other objects.

Note Metadata fields start with an underscore (_). For example, _createdOn reports the time when the object was created.

Scalar filters

Most objects have some fields that can be filters for a query or mutation. The filters that are available depend on the data type, but the behavior of the String filters corresponds closely to DateTime and Int filters.

String filters

String properties have the following filters:

FilterDescriptionExample argument
eqEquals (exact match)(filter: {id: {eq: "match"}})
inFrom this match of arrays(filter: {id: {in: ["dough", "cookie_unit"]}})
lt,gt,le, ge betweenLess than, greater than, or between a lexicographic range(filter: {id: {lt: "M"}
regexpA regular expression match using RE2 syntax(filter: {id: {regexp: "/hello/i"}})
anyoftextA match for any entered strings, separated by spaces(filter: {id: {anyoftext: "100 MD"}})
alloftextA match for all entered strings(filter: {id {alloftext: "MD"}})

Integers, floats, DateTimes

Properties that have a type of Int, Float, or DateTime can be filtered by the following keywords.

  • lt
  • le
  • eq
  • in
  • between
  • ge
  • gt

Each keyword has the same behavior as described in string filters, only they operate on numerical rather than lexicographic values.

Note While the dateTime type uses the RFC 3339 format, some string fields may use the ISO 8601 format. This depends on the object and customer requirement. For these fields, the string filters work as chronological filters too.

Enum filters

Properties of the type Enum can be filtered by the following:

  • lt
  • le
  • eq
  • in
  • between
  • ge
  • gt

Each keyword has the same behavior as described in string filters.

Boolean filters

Boolean filters can be either true or false.

Geolocation filters

Geolocation filters return objects within specified geographic coordinates. They return matches within the specified GeoJSON polygon.

If a geolocation field can act as a filter, then the filter can work in one of the following behaviors:

FilterDescription
nearWithin the specified distance from the polygon
withinIn the polygon coordinates
IntersectsIn the intersection of two polygons

Read more