ContentTypeQuery

public final class ContentTypeQuery : ChainableQuery

Queries on content types. All methods from ChainableQuery are available, are inherited and available.

  • The parameters dictionary that is converted to URLComponents (HTTP parameters/arguments) on the HTTP URL. Useful for debugging.

    Declaration

    Swift

    public var parameters: [String : String]
  • Designated initalizer for Query.

    Declaration

    Swift

    public required init()
  • Static method for creating a ContentTypeQuery with an operation. This variation for initializing guarantees correct query contruction by utilizing the ContentType.QueryableCodingKey CodingKeys.

    Example usage:

    let query = ContentTypeQuery.where(queryableCodingKey: .name, .equals("Cat"))
    client.fetchArray(of: ContentType.self, matching: query) { (result: Result<ArrayResponse<ContentType>>) in
        switch result {
        case .success(let arrayResponse):
            let contentTypes = arrayResponse.items
            // Do stuff with contentTypes.
        case .failure(let error):
            print(error)
        }
    }
    

    See: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters

    Declaration

    Swift

    public static func `where`(queryableCodingKey: ContentType.QueryableCodingKey, _ operation: Query.Operation) -> ContentTypeQuery

    Parameters

    queryableCodingKey

    The member of your ContentType.QueryableCodingKey that you are performing your operation against.

    operation

    The query operation used in the query.

    Return Value

    A newly initialized AssetQuery query.

  • Instance method for appending a query operation to the receiving ContentTypeQuery. This variation for initializing guarantees correct query construction by utilizing the ContentType.QueryableCodingKey CodingKeys.

    Example usage:

    let query = ContentTypeQuery().where(queryableCodingKey: .name, .equals("Cat"))
    client.fetchArray(of: ContentType.self, matching: query) { (result: Result<ArrayResponse<ContentType>>) in
        switch result {
        case .success(let arrayResponse):
            let contentTypes = arrayResponse.items
            // Do stuff with contentTypes.
        case .failure(let error):
            print(error)
        }
    }
    

    See: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters

    Declaration

    Swift

    @discardableResult
    public func `where`(queryableCodingKey: ContentType.QueryableCodingKey, _ operation: Query.Operation) -> ContentTypeQuery

    Parameters

    queryableCodingKey

    The member of your ContentType.QueryableCodingKey that you are performing your operation against.

    operation

    The query operation used in the query.

    Return Value

    A reference to the receiving query to enable chaining.