Skip to content

Instantly share code, notes, and snippets.

View lorensr's full-sized avatar

Loren ☺️ lorensr

View GitHub Profile
hcp-repro $ meteor run android-device --mobile-server "192.168.0.189:3000"
[[[[[ ~/jobs/hcp-repro ]]]]]
=> Started proxy.
WARNING: Attempting to install plugin cordova-plugin-statusbar@2.2.1, 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 cordova-plugin-splashscreen@4.0.1, 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
=> 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
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))
}
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))
}
import { InMemoryLRUCache } from 'apollo-server-caching'
...
initialize({ context, cache } = {}) {
this.context = context
this.cache = cache || new InMemoryLRUCache()
}
didEncounterError(error) {
throw error
}
cacheKey(id) {
return `foo-${this.db.connectionURI}-${id}`
}
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 })
async update(id, newDoc) {
try {
await this.db.update(id, newDoc)
this.cache.delete(this.cacheKey(id))
} catch (error) {
this.didEncounterError(error)
}
}
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
})