Skip to content

Instantly share code, notes, and snippets.

@lorensr
Created April 8, 2020 19:15
Show Gist options
  • Save lorensr/9c09da895fa0096ed58c2e883b16ff88 to your computer and use it in GitHub Desktop.
Save lorensr/9c09da895fa0096ed58c2e883b16ff88 to your computer and use it in GitHub Desktop.
import { DataSource } from 'apollo-datasource'
import { InMemoryLRUCache } from 'apollo-server-caching'
import DataLoader from 'dataloader'
class FooDataSource extends DataSource {
constructor(dbClient) { ... }
initialize({ context, cache } = {}) { ... }
didEncounterError(error) { ... }
cacheKey(id) { ... }
async get(id, { ttlInSeconds } = {}) { ... }
async update(id, newDoc) { ... }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment