Each field on the sObject has a corresponding input object field on the Filter type. The input object field has an Operators type. For example, Account has a field Name of type String, and so the AccountFilter input object has an input object field Name of type StringOperators.
Each Operators type exposes the filtering capabilities of that field type. Each field type that supports filtering has a corresponding Operators type. The Operators type has one input object field for each filtering capability of the underlying data type. For example, the StringOperators type can compare String values based on equality and ordering.
If multiple operations are specified on an Operator, both operations are included in the query and AND’d together. For example, where: {AnnualRevenue: {gt: 10000, lt: 100000}} finds records with an annual revenue of more than 10000 and less than 100000.
Tip
GraphQL supports multiple operators in queries. See Boolean Operators for more information and examples.
Field Functions
Each field on the Operators type corresponds to the following functions.
Function
Description
eq
Equals. The expression is true if the field value equals the value in the expression. String comparisons are case-insensitive. For example, Name: { eq: "Genepoint" } returns the same result as Name: { eq: "GenePoint" }
ne
Not equals. The expression is true if the field value doesn’t equal the specified value.
lt
Less than. The expression is true if the field value is less than the specified value.
gt
Greater than. The expression is true if the field value is greater than the specified value.
lte
Less than or equal. The expression is true if the field value is less than, or equals, the specified value.
gte
Greater than or equal. The expression is true if the field value is greater than or equal to the specified value.
like
The expression is true if the field value matches the characters of the specified value. Supported for string fields only.
in
Is an element within a static set of items. For example, Name: { in: ["Genepoint", "Edge Communications"] }
nin
Is not an element within a static set of items
inq
Is an element in query. Use this function to create a semi-join filter.
ninq
Is not an element in query. Use this function to create an anti-join filter.
Fields on sObjects have corresponding mappings to Operators types. The main field types are:
These field types are discussed in the following sections.
String Field Types
Operators for field types Email, TextArea, LongTextArea, Url, and PhoneNumber are similar to StringOperators, but they use the appropriate scalar for the input object field type.
Operators for field types Currency, Percent, Longitude, and Latitude are similar to DoubleOperators, but they use the appropriate scalar for the input object field type. The Operator for the Long field type is similar to IntegerOperators, but uses Long instead of Int.
Double Fields
Double fields map to the DoubleOperators filter type.
Date and DateTime fields support additional filtering criteria beyond the standard set of operators defined on other types. Rather than the input object fields of the Operators type being the scalar type, they are of input object type DateInput and DateTimeInput respectively.
In addition to a different type for the individual operators, Date and DateTime Operators support additional functions related to the relative time of the field value. These input object field types are DateFunctionInput and DateTimeFunctionInput.
DateInput facilitates operating on Date fields by more than just the exact value of a particular Date.
DateInput
1input DateInput{2 value: Date # An exact Date value3 literal: DATE_LITERAL # a literal value for a relative time4 range: DateRange # a range of Dates5}
DateTime fields map to the DateTimeInput filter type.
DateTimeInput
1input DateTimeInput{2 value: DateTime # An exact DateTime value3 literal: DATE_LITERAL # a literal value for a relative time4 range: DateRange # a range of Dates5}
1input DateTimeFunctionInput{2 value: DateTimePrimitiveOperators # a value in UTC3 convertTimezoneValue: DateTimePrimitiveOperators # convert the value to the default time zone4}
DateTime primitive operators allow working with DateTime values directly.
Either the 15-character and 18-character ID values is accepted. For example. Account( where: { Id: { eq: "0011a000005slme" } } ) returns the same result as Account( where: { Id: { eq: "0011a000005slmeAAA" } } ).
The inq and ninq operators (in-query and not-in-query) are of the JoinInput type. Use these operators to execute semi-join and anti-join queries.
Picklist Field Type
Picklist fields map to the PicklistOperators filter type.