This file contains 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
hcp-repro $ meteor run android-device --mobile-server "192.168.0.189:3000" | |
[[[[[ ~/jobs/hcp-repro ]]]]] | |
=> Started proxy. | |
WARNING: Attempting to install plugin [email protected], but it should have a minimum version of 2.3.0 to ensure compatibility with the | |
current platform versions. Installing the minimum version for convenience, but you should adjust your dependencies. | |
WARNING: Attempting to install plugin [email protected], but it should have a minimum version of 4.1.0 to ensure compatibility with the | |
current platform versions. Installing the minimum version for convenience, but you should adjust your dependencies. | |
=> Started MongoDB. | |
Subproject Path: CordovaLibns [=========== ] 40% 8.4s |
This file contains 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
=> App running at: http://localhost:3000/ | |
=> Started app on Android Device. | |
I20190113-01:03:51.333(1)? I/CordovaLog(29528): Changing log level to DEBUG(3) | |
I20190113-01:03:51.364(1)? I/chromium(29528): [INFO:library_loader_hooks.cc(36)] Chromium logging enabled: level = 0, default verbosity = 0 | |
I20190113-01:03:51.364(1)? W/MeteorWebApp(29528): Loading asset bundle from directory file:///android_asset/www/application | |
I20190113-01:03:51.364(1)? W/MeteorWebApp(29528): Asset / found in bundle b96242b11ac30d186162794a8281039a4c641e89:file:///android_asset/www/application | |
I20190113-01:03:51.364(1)? W/MeteorWebApp(29528): Asset /__cordova/merged-stylesheets.css found in bundle b96242b11ac30d186162794a8281039a4c641e89:file:///android_asset/www/application | |
I20190113-01:03:51.364(1)? W/MeteorWebApp(29528): Asset /cordova.js not found in bundle b96242b11ac30d186162794a8281039a4c641e89:file:///android_asset/www/application, no parent bundle | |
I20190113-01:03:51.365(1)? W/MeteorWebApp(29528): Asset /__cordova/packages/meteor |
This file contains 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 { DataSource } from 'apollo-datasource' | |
import { InMemoryLRUCache } from 'apollo-server-caching' | |
import DataLoader from 'dataloader' | |
class FooDataSource extends DataSource { | |
constructor(dbClient) { | |
super() | |
this.db = dbClient | |
this.loader = new DataLoader(ids => dbClient.getByIds(ids)) | |
} |
This file contains 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 { DataSource } from 'apollo-datasource' | |
import DataLoader from 'dataloader' | |
class FooDataSource extends DataSource { | |
constructor(dbClient) { | |
super() | |
this.db = dbClient | |
this.loader = new DataLoader(ids => dbClient.getByIds(ids)) | |
} |
This file contains 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 { InMemoryLRUCache } from 'apollo-server-caching' | |
... | |
initialize({ context, cache } = {}) { | |
this.context = context | |
this.cache = cache || new InMemoryLRUCache() | |
} |
This file contains 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
didEncounterError(error) { | |
throw error | |
} |
This file contains 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
cacheKey(id) { | |
return `foo-${this.db.connectionURI}-${id}` | |
} |
This file contains 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
async get(id, { ttlInSeconds } = {}) { | |
const cacheDoc = await cache.get(this.cacheKey(id)) | |
if (cacheDoc) { | |
return JSON.parse(cacheDoc) | |
} | |
const doc = await this.loader.load(id) | |
if (ttlInSeconds) { | |
cache.set(this.cacheKey(id), JSON.stringify(doc), { ttl: ttlInSeconds }) |
This file contains 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
async update(id, newDoc) { | |
try { | |
await this.db.update(id, newDoc) | |
this.cache.delete(this.cacheKey(id)) | |
} catch (error) { | |
this.didEncounterError(error) | |
} | |
} |
This file contains 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 FooDataSource from './FooDataSource' | |
import { reportError } from './utils' | |
export default class MyFooDB extends FooDataSource { | |
async updateFields(id, fields) { | |
const doc = await this.get(id) | |
return this.update(id, { | |
...doc, | |
...fields | |
}) |