Skip to content

Instantly share code, notes, and snippets.

View danielrearden's full-sized avatar

Daniel Rearden danielrearden

View GitHub Profile
@danielrearden
danielrearden / schema.graphql
Created May 15, 2020 04:06
Making GraphQL Magic with Sqlmancer - 1
type Customer @model(
table: "customers"
pk: "CustomerId"
) {
id: ID! @col(name: "CustomerId")
firstName: String!
lastName: String!
email: String!
}

Keybase proof

I hereby claim:

  • I am danielrearden on github.
  • I am danielrearden (https://keybase.io/danielrearden) on keybase.
  • I have a public key ASCcI8cGL1AfbfSgjEtpUtk5ELxgPuHf9mZqLdbEjz8EbQo

To claim this, I am signing this object:

import crypto from 'crypto'
import redis from 'services/redis'
export async function queryWrapper (query, ttl) {
// these could also be passed explicitly to the function, but that may leave more room for error?
let table, method
query.modify(qb => {
table = qb._table || 'some_fallback'
method = qb._method
})
@danielrearden
danielrearden / createMockRow.js
Last active July 20, 2017 19:17
createMockRow
const chance = require('chance')
module.exports = (db, table, specificProps) => db.raw(`
SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = '${table}';
`).then((cols) => cols.reduce((memo, col) => {
switch (col.data_type) {
case 'uuid': return Object.assign({ [col.column_name]: chance.guid() }, memo);
case 'character varying': return Object.assign({ [col.column_name]: chance.word() }, memo);