-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/query operators #45
Conversation
ba44680
to
e958a61
Compare
Remove unnecessary generic protocol abstraction
while preserving the benefits of generics
Make a protocol called ClientFieldst that users will conform to help them map fields. map identifier like, entry.sys.id Add ObjectMapper and replace Deodable, Wrap Link's in an Enum to make them stateful
Debug Link resolution for one-to-one links Debug Link resoulution for one-to-many links
Debug SyncSpace, API Error parsing, content type decoding & Include resolution Use ImmutableMappable Reimplement Decoding tests and rename then ObjectMappingTests Make query syntax read better Update ContentModel protocol to be easier to make use of
Separate code paths for query'ing entries and assets Don't restrict ContentModel to class types
ee87db7
to
051775a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small improvements I'd like to suggest ...
Sources/Decoding.swift
Outdated
private func parseLocalizedFields(_ json: Any) throws -> (String, [String:[String:Any]]) { | ||
let fields = try json => "fields" as! [String: Any] | ||
let locale: String? = try? json => "sys" => "locale" | ||
//internal extension String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we either uncomment or remove?
Sources/Link.swift
Outdated
|
||
public let id: String | ||
|
||
public let linkType: String // "Entry" or "Asset" (-> Easier to resolve with this information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
being picky )
is missing at the end of the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just rm this comment. It was just for me ;-)
Sources/Query.swift
Outdated
} | ||
} | ||
|
||
// internal static func validatecombinationsRecursively(operations: QueryOperation...) throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To comment or to delete, that is here the question ... ;)
Sources/Query.swift
Outdated
extension String { | ||
|
||
func isValidSelection() -> Bool { | ||
if characters.split(separator: ".").count > 2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fields..foo
will still pass... What about fields..foo".characters.split(separator:".", maxSplits:34, omittingEmptySubsequences:false)
Sources/Sys.swift
Outdated
createdAt = try? map.value("createdAt") | ||
updatedAt = try? map.value("updatedAt") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to map space
and revision
too?
Tests/EntryTests.swift
Outdated
case .asset(let image): | ||
expect(url(image).absoluteString).to(equal("https://images.contentful.com/cfexampleapi/4gp6taAwW4CmSgumq2ekUm/9da0cd1936871b8d72343e895a00d611/Nyan_cat_250px_frame.png")) | ||
default: | ||
fail("Should not have a link of the wrong type her") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here
?
Tests/LinkTests.swift
Outdated
let entry = Entry(localizedField: ["":["":""]]) | ||
let link = Link.entry(entry) | ||
let newLink = Link.link(from: link) | ||
expect(newLink).toNot(beNil()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this test be more explicit? I.e. what about changing it from .toNot(beNil())
to testing if the newLink
sys.id equals the linked entry id, or so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooops, I thought I had deleted this file. Turns out i only removed it from the xcode project index. It's not a necessary test.
Tests/QueryTests.swift
Outdated
|
||
|
||
// PERSISTENCE | ||
//final class Cat: NSManagedObject, ContentModel { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are those tests to be used once persistence is updated, or can we uncomment them, make them useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops. i forgot to address those. I'll remove them
|
||
switch result { | ||
case .success(let dogs): | ||
let doge = dogs.first! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it wise to depend on the undefined ordering here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure...any better ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes: Also request an ordering by any field ... ;)
} catch let error as QueryError { | ||
expect(error.message).toNot(beNil()) | ||
} catch _ { | ||
fail("Should throw a QueryError") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need to catch the exception here, or can you let it bubble through to the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm catching here to make sure that the error thrown is the right type of Error
. So yes, I do indeed need to catch it now.
d6c073f
to
d0614cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙆♂️
No description provided.