import Item from "./db/item"
import { default as ItemType } from "./graphql/types/item"
import { makeExecutableSchema } from "graphql-tools"
import Update from "./graphql/types/update"

const RuneScapeQuery = `
	type RuneScapeQuery {
		items: [Item]
		item(id: Int): Item
		updates: [Update]
	}
`

const SchemaDefinition = `
	schema {
		query: RuneScapeQuery
	}
`

const fetchItem = id => Item.findOne({ id }, { rsbuddy: false })
const fetchItems = () => Item.find({}, { rsbuddy: false })

export default makeExecutableSchema({
  typeDefs: [SchemaDefinition, RuneScapeQuery, ItemType, Update],
  resolvers: {
    RuneScapeQuery: {
      items: (root, args) => fetchItems(),
      item: (root, { id }) => fetchItem(id)
    }
  }
})

@@ -8,56 +8,8 @@
 Item
- from %22./db/item%22%0Aimport %7B default as ItemType %7D
  fro
@@ -89,52 +89,8 @@
 ols%22
-%0Aimport Update from %22./graphql/types/update%22
 %0A%0Aco
@@ -112,17 +112,18 @@
 ery = %60%0A
-%09
+  
 type Run
@@ -136,18 +136,20 @@
 Query %7B%0A
-%09%09
+    
 items: %5B
@@ -154,18 +154,20 @@
  %5BItem%5D%0A
-%09%09
+    
 item(id:
@@ -174,16 +174,17 @@
  Int
+!
 ): Item%0A
 %09%09up
@@ -179,18 +179,20 @@
 ): Item%0A
-%09%09
+    
 updates:
@@ -201,17 +201,18 @@
 Update%5D%0A
-%09
+  
 %7D%0A%60%0A%0Acon
@@ -279,73 +279,8 @@
 %0A%60%0A%0A
-const fetchItem = id =%3E Item.findOne(%7B id %7D, %7B rsbuddy: false %7D)%0A
 cons
@@ -428,12 +428,8 @@
 Item
-Type
 , Up
@@ -496,73 +496,296 @@
 ot, 
-args) =%3E fetchItems(),%0A      item: (root, %7B id %7D) =%3E fetchItem(id
+%7B ids %7D, %7B models %7D) =%3E%0A        models.items.find(%7B%7D, %7B _id: false, rsbuddy: false %7D),%0A      item: (root, %7B id %7D, %7B models %7D) =%3E%0A        models.items.findOne(%7B id %7D, %7B _id: false, rsbuddy: false %7D),%0A      updates: (root, args, %7B models %7D) =%3E%0A        models.updates.find(%7B%7D, %7B _id: false %7D
 )%0A  

Clean up main graphql module