Last active
March 6, 2018 17:26
-
-
Save emarashliev/02e0ed6676910b69c360d3d6e1346ac1 to your computer and use it in GitHub Desktop.
Apollo with SQLite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Apollo | |
let path = NSSearchPathForDirectoriesInDomains( .documentDirectory, .userDomainMask, true).first! | |
let url = URL(string: "http://localhost:3000/graphql")! | |
let cache = try! SQLiteNormalizedCache(fileURL: URL(string: "\(path)/db.sqlite3")!) | |
let apollo = ApolloClient(networkTransport: HTTPNetworkTransport(url: url), store: ApolloStore(cache: cache)) | |
apollo.fetch(query: AllReceiptsQuery()){ (result, error) in | |
print(result?.data?.receipts?.first) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment