Skip to content

Add initializer that takes database Connection#1330

Merged
designatednerd merged 1 commit intoapollographql:mainfrom
mdarnall:inject-connection
Jul 27, 2020
Merged

Add initializer that takes database Connection#1330
designatednerd merged 1 commit intoapollographql:mainfrom
mdarnall:inject-connection

Conversation

@mdarnall
Copy link
Copy Markdown

@mdarnall mdarnall commented Jul 27, 2020

Updated SQLiteNormalizedCache

Because:

This commit:

  • Adds a new initializer to SQLiteNormalizedCache

@apollo-cla
Copy link
Copy Markdown

@mdarnall: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

Copy link
Copy Markdown
Contributor

@designatednerd designatednerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment I can fix post-merge if you'd prefer - otherwise looks good!


func testPassInConnection() {
let connection = try? Connection()
XCTAssertNotNil(connection)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend making the test a throws test so you don't have to mess around with unwrapping:

func testPassInConnection() throws {
  let connection = try Connection()
  let cache = try SQLiteNormalizedCache(db: connection)
  // Something that tests that the cache exists
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sure I can update that.. thanks

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@designatednerd I updated this to hopefully simplify, but didn't know if there was really a good way to "tests that the cache exists". Instead, I'm simply asserting the creation does not throw.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works too!

Because:
- It will allow consumers to further configure the Connection in their
application and pass it in
- See: https://github.com/apollographql/apollo-ios/pull/1162/files#r410367735
This commit:
- Adds a new initializer to SQLNormalizedCache
@mdarnall mdarnall force-pushed the inject-connection branch from 38acd17 to d6a4d03 Compare July 27, 2020 21:38
Copy link
Copy Markdown
Contributor

@designatednerd designatednerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 pending CI

@designatednerd designatednerd merged commit 791b70a into apollographql:main Jul 27, 2020
@designatednerd designatednerd added this to the Next Release milestone Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants