AbstractResourceQuery
public protocol AbstractResourceQuery : ChainableQuery
A base abtract type which holds methods and constructors for all valid queries against resource: i.e. Contentful entries and assets.
-
localizeResults(withLocaleCode:
Extension method) Static method to create a query which specifies the locale of the entries that should be returned. If there’s no content available for the requested locale the API will try the fallback locale of the requested locale.
Declaration
Swift
static func localizeResults(withLocaleCode localeCode: LocaleCode) -> Self
Parameters
localeCode
The code for the locale you would like to specify.
Return Value
A newly created query with the results restricted to the specified locale.
-
localizeResults(withLocaleCode:
Extension method) Instance method for further mutating a query which specifies the locale of the entries that should be returned If there’s no content available for the requested locale the API will try the fallback locale of the requested locale.
Declaration
Swift
@discardableResult func localizeResults(withLocaleCode localeCode: LocaleCode) -> Self
Parameters
localeCode
The code for the locale you would like to specify.
Return Value
A reference to the receiving query to enable chaining.
-
select(fieldsNamed:
Extension method) Initializes a select operation query in which only the fields specified in the fieldNames property will be returned in the JSON response. The
"sys"
property is always requested by the SDK. Note that if you are using the select operator with an instanceQueryOn<EntryType>
that your model types must have optional types for properties that you are omitting in the response (by not including them in your selections array). If you are not using theQueryOn
type while querying entries, make sure to specify the content type id. Example usage:let query = try! Query.select(fieldsNamed: ["bestFriend", "color", "name"]).where(contentTypeId: "cat") client.fetchMappedEntries(with: query).observable z { catsResponse in let cats = catsResponse.items // Do stuff with cats. }
Throws
An error if selections go more than 1 level deep within the fields container (“bestFriend.sys” is not valid), or if more than 99 properties are selected.Declaration
Swift
static func select(fieldsNamed fieldNames: [FieldName]) throws -> Self
Parameters
fieldNames
An array of field names to include in the JSON response.
Return Value
A newly initialized query selecting only certain fields to be returned in the response.
-
select(fieldsNamed:
Extension method) Instance method for select operation in which only the fields specified in the
fieldNames
parameter will be returned in the JSON response. The"sys"
dictionary is always requested by the SDK. Note that if you are using the select operator with an instanceQueryOn<EntryType>
that you must make properties that you are ommitting in the response (by not including them in your selections array) optional properties. Example usage:let query = try! Query().select(fieldsNamed: ["bestFriend", "color", "name"]) client.fetchEntries(with: query) { (result: Result<ArrayResponse<Cat>>) in switch result { case .success(let arrayResponse): let cats = arrayResponse.items // Do stuff with cats. case .failure(let error): print(error) } }
Throws
An error if selections go more than 1 level deep within the fields container (“bestFriend.sys” is not valid), or if more than 99 properties are selected.Declaration
Swift
@discardableResult func select(fieldsNamed fieldNames: [FieldName]) throws -> Self
Parameters
fieldNames
An array of field names to include in the JSON response.
Return Value
A reference to the receiving query to enable chaining.