From 9e4008ebceb873656364db1b7ce5e61a64519596 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Sat, 28 Mar 2020 11:02:14 -0600 Subject: [PATCH] updates --- .../mimi-server--structured/README.md | 4 ++++ .../mimi-server--structured/index.js | 9 ++------- .../mimi-server--structured/package.json | 1 - .../mimi-server--structured/resolvers.js | 9 +++++++++ .../mimi-server--structured/schema.js | 18 ++++++++++++++++++ 5 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 data-services/html-source/mimi-server--structured/README.md create mode 100644 data-services/html-source/mimi-server--structured/resolvers.js create mode 100644 data-services/html-source/mimi-server--structured/schema.js diff --git a/data-services/html-source/mimi-server--structured/README.md b/data-services/html-source/mimi-server--structured/README.md new file mode 100644 index 0000000..fe5a2c6 --- /dev/null +++ b/data-services/html-source/mimi-server--structured/README.md @@ -0,0 +1,4 @@ +# This simple example performs the same functionality as the example found in ../mimi-server, but uses graphql-tools from Apollo + +See https://www.apollographql.com/docs/graphql-tools/ for documentation + diff --git a/data-services/html-source/mimi-server--structured/index.js b/data-services/html-source/mimi-server--structured/index.js index 3a12e24..95b5a7e 100644 --- a/data-services/html-source/mimi-server--structured/index.js +++ b/data-services/html-source/mimi-server--structured/index.js @@ -1,10 +1,5 @@ const { ApolloServer, gql } = require('apollo-server'); const fetch = require('node-fetch'); const cheerio = require('cheerio'); - -import { makeExecutableSchema } from 'graphql-tools'; - -export const schema = makeExecutableSchema({ - typeDefs, - resolverMap, -}); \ No newline at end of file +const { resolverMap } = require('./resolvers'); +// const schema = require('schema'); diff --git a/data-services/html-source/mimi-server--structured/package.json b/data-services/html-source/mimi-server--structured/package.json index e7874db..3e8d17a 100644 --- a/data-services/html-source/mimi-server--structured/package.json +++ b/data-services/html-source/mimi-server--structured/package.json @@ -13,7 +13,6 @@ "apollo-server": "^2.11.0", "cheerio": "^1.0.0-rc.3", "graphql": "^14.6.0", - "graphql-tools": "^4.0.7", "node-fetch": "^2.6.0" }, "devDependencies": { diff --git a/data-services/html-source/mimi-server--structured/resolvers.js b/data-services/html-source/mimi-server--structured/resolvers.js new file mode 100644 index 0000000..6120853 --- /dev/null +++ b/data-services/html-source/mimi-server--structured/resolvers.js @@ -0,0 +1,9 @@ +const resolverMap = { + Query: { + collections: async(_, args) => { + return getCollections(args.kind) + } + }, +} + +export default resolverMap; \ No newline at end of file diff --git a/data-services/html-source/mimi-server--structured/schema.js b/data-services/html-source/mimi-server--structured/schema.js new file mode 100644 index 0000000..0f74e0d --- /dev/null +++ b/data-services/html-source/mimi-server--structured/schema.js @@ -0,0 +1,18 @@ +const { gql } = require('apollo-server'); + +const typeDefs = gql` + "Collection defines the queryable fields for every collection in mimi" + type Collection { + "The collection title" + title: String + href: String + backgroundImage: String + } + + type Query { + "The collections query returns an array of zero or more Collections" + collections("What kind of collection, e.g. thesis" kind: String!): [Collection] + } +` + +export default typeDefs; \ No newline at end of file