Skip to content

Commit

Permalink
Add prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
lorensr committed Jan 22, 2020
1 parent 996caf8 commit d75ced7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 34 deletions.
32 changes: 10 additions & 22 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
module.exports = {
"env": {
"es6": true,
"node": true
env: {
es6: true,
node: true
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"never"
]
extends: 'eslint:recommended',
rules: {
indent: ['error', 2],
'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
semi: ['error', 'never']
}
};
}
2 changes: 2 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
singleQuote: true
semi: false
30 changes: 18 additions & 12 deletions src/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ const resolvers = {
Query: {
// call joinMonster in the "user" resolver, and all child fields that are tagged with "sqlTable" are handled!
user(parent, args, ctx, resolveInfo) {
return joinMonster(resolveInfo, ctx, sql => {
return db.all(sql)
}, { dialect: 'sqlite3' })
return joinMonster(
resolveInfo,
ctx,
sql => {
return db.all(sql)
},
{ dialect: 'sqlite3' }
)
}
},
User: {
Expand Down Expand Up @@ -77,10 +82,11 @@ joinMonsterAdapt(schema, {
sqlColumn: 'email_address'
},
fullName: {
sqlDeps: [ 'first_name', 'last_name' ],
sqlDeps: ['first_name', 'last_name']
},
posts: {
sqlJoin: (userTable, postTable) => `${userTable}.id = ${postTable}.author_id`,
sqlJoin: (userTable, postTable) =>
`${userTable}.id = ${postTable}.author_id`
}
}
},
Expand All @@ -90,7 +96,8 @@ joinMonsterAdapt(schema, {
fields: {
numComments: {
// count with a correlated subquery
sqlExpr: table => `(SELECT count(*) FROM comments where ${table}.id = comments.post_id)`
sqlExpr: table =>
`(SELECT count(*) FROM comments where ${table}.id = comments.post_id)`
},
comments: {
// fetch the comments in another batch request instead of joining
Expand Down Expand Up @@ -135,9 +142,8 @@ const query = `{
}`

db.open(path.join(__dirname, '..', 'db', 'test1-data.sl3'))
.then(() => graphql(schema, query))
.then(res => {
console.log(require('util').inspect(res, { depth: 10 })) // eslint-disable-line
})
.catch(console.error) // eslint-disable-line

.then(() => graphql(schema, query))
.then(res => {
console.log(require('util').inspect(res, { depth: 10 })) // eslint-disable-line
})
.catch(console.error) // eslint-disable-line

0 comments on commit d75ced7

Please sign in to comment.