-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
55 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,35 @@ | ||
import BaseDao from '../db/baseDao' | ||
|
||
const customDefs = ` | ||
type Post { | ||
id: Int! | ||
title: String | ||
} | ||
` | ||
|
||
let queryDefs = ['posts: [Post]'] | ||
const customDefs = { | ||
textDefs: ` | ||
type Post { | ||
id: Int! | ||
title: String | ||
author: Author | ||
} | ||
`, | ||
queryDefs: ['posts: [Post]'], | ||
mutationDefs: ['addPost(title: String!, author_id: Int!): ReviseResult'] | ||
} | ||
|
||
const customResolvers = { | ||
Query: { | ||
posts: async () => { | ||
let rs = await new BaseDao('book').retrieve({}) | ||
return rs.data | ||
} | ||
}, | ||
Mutation: { | ||
addPost: (_, args) => { | ||
return new BaseDao('book').create(args) | ||
} | ||
}, | ||
Post: { | ||
author: async (element) => { | ||
let rs = await new BaseDao('author').retrieve({ id: element.author_id }) | ||
return rs.data[0] | ||
} | ||
} | ||
} | ||
|
||
export { customDefs, queryDefs, customResolvers } | ||
export { customDefs, customResolvers } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
const customDefs = ` | ||
type ReviseResult { | ||
id: Int | ||
affectedRows: Int | ||
status: Int | ||
message: String | ||
} | ||
` | ||
|
||
let queryDefs = [] | ||
const customDefs = { | ||
textDefs: ` | ||
type ReviseResult { | ||
id: Int | ||
affectedRows: Int | ||
status: Int | ||
message: String | ||
} | ||
`, | ||
queryDefs: [], | ||
mutationDefs: [] | ||
} | ||
|
||
const customResolvers = { Query: {} } | ||
const customResolvers = { | ||
Query: { | ||
}, | ||
Mutation: { | ||
} | ||
} | ||
|
||
export { customDefs, queryDefs, customResolvers } | ||
export { customDefs, customResolvers } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters