Field Operators

AVAILABLE API VERSION
API v56.0 and later

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.

GraphQL supports multiple operators in queries. See Boolean Operators for more information and examples.

Each field on the Operators type corresponds to the following functions.

FunctionDescription
eqEquals. 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" }
neNot equals. The expression is true if the field value doesn’t equal the specified value.
ltLess than. The expression is true if the field value is less than the specified value.
gtGreater than. The expression is true if the field value is greater than the specified value.
lteLess than or equal. The expression is true if the field value is less than, or equals, the specified value.
gteGreater than or equal. The expression is true if the field value is greater than or equal to the specified value.
likeThe expression is true if the field value matches the characters of the specified value. Supported for string fields only.
inIs an element within a static set of items. For example, Name: { in: ["Genepoint", "Edge Communications"] }
ninIs not an element within a static set of items
inqIs an element in query. Use this function to create a semi-join filter.
ninqIs 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.

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.

The like operator behaves similarly to the WHERE SOSL expression.

String fields map to the StringOperators filter type.

Email fields map to the EmailOperators filter type.

PhoneNumber fields map to the PhoneNumberOperators filter type.

TextArea fields map to the TextAreaOperators filter type.

LongTextArea fields map to the LongTextAreaOperators filter type.

Url fields map to the URLOperators filter 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 map to the DoubleOperators filter type.

Int fields map to the IntegerOperators filter type.

Long fields map to the LongOperators filter type.

Currency fields map to the CurrencyOperators filter type.

Percent fields map to the PercentOperators 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.

Date fields are mapped to DateOperators.

DateInput facilitates operating on Date fields by more than just the exact value of a particular Date.

Date literals represent a relative range of time, such as last month, this week, or next year. See SOQL and SOSL Reference: Date Formats and Date Literals in WHERE Clauses.

Range values for dates capture dates within a period of time. See SOQL and SOSL Reference: Date Formats and Date Literals in WHERE Clauses.

Date functions help you convert date values to the default time zone. See SOQL and SOSL Reference: Converting Time Zones in Date Functions.

DateTime fields map to the DateTimeOperators filter type.

DateTime fields map to the DateTimeInput filter type.

DateTime functions help you convert date time values to the default time zone. See SOQL and SOSL Reference: Converting Time Zones in Date Functions.

DateTime primitive operators allow working with DateTime values directly.

Time fields map to the TimeOperators filter type.

Boolean fields map to the BooleanOperators filter type.

ID fields map to the IdOperators filter type.

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 fields map to the PicklistOperators filter type.

Multi-picklist fields map to the MultiPicklistOperators filter type.

Latitude fields map to the LatitudeOperators filter type.

Longitude fields map to the LongitudeOperators filter type.

A compound field of type Geolocation maps to the GeolocationOperators filter type.

For GeolocationOperators, the lt and gt operators are of the GeolocationInput type.

Use the geolocation operators to run location-based queries.

Here are a few sample arguments to demonstrate how to filter on a field.

This example uses multiple operations on a single operator type. The two conditions are AND'd together.

This example finds opportunities whose NextStep equals "Need estimate".

This example queries accounts whose names match a given string.

This example finds accounts with an annual revenue of more than 1 million.