From d75ced7cf1d035a0f420cf752fbd22fa0fe0aaa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Loren=20=F0=9F=A4=93?= Date: Wed, 22 Jan 2020 02:15:32 -0500 Subject: [PATCH] Add prettier --- .eslintrc.js | 32 ++++++++++---------------------- .prettierrc | 2 ++ src/schema.js | 30 ++++++++++++++++++------------ 3 files changed, 30 insertions(+), 34 deletions(-) create mode 100644 .prettierrc diff --git a/.eslintrc.js b/.eslintrc.js index 1c98b11..21d2e50 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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'] } -}; +} diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..8ded5e0 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,2 @@ +singleQuote: true +semi: false diff --git a/src/schema.js b/src/schema.js index 088ba85..3dd7656 100644 --- a/src/schema.js +++ b/src/schema.js @@ -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: { @@ -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` } } }, @@ -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 @@ -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