diff --git a/data-services/html-source/mimi-server--structured/README.md b/data-services/html-source/mimi-server--structured/README.md index 6f8b2b2..fec7404 100644 --- a/data-services/html-source/mimi-server--structured/README.md +++ b/data-services/html-source/mimi-server--structured/README.md @@ -4,9 +4,7 @@ This is a fairly standard structure, with the schema and resolvers in to their o ## Other changes from ../mimi-server -### import and export instead of require - -[esm](https://www.npmjs.com/package/esm) is used to provide support for standard JavaScript import and export, which are not supported natively in node yet (as of 13.9). The `--experimental-support` flag could also be used if one does not want to use esm. - +Uses import and export instead of require +See https://github.com/apollographql/apollo-server/issues/3786 for workaround to address issue in apollo-server import diff --git a/data-services/html-source/mimi-server--structured/collections.js b/data-services/html-source/mimi-server--structured/collections.js index 4f7b04f..cc1665a 100644 --- a/data-services/html-source/mimi-server--structured/collections.js +++ b/data-services/html-source/mimi-server--structured/collections.js @@ -1,7 +1,6 @@ -const fetch = require('node-fetch'); +import fetch from 'node-fetch'; import cheerio from 'cheerio'; - const getCollections = async(kind) => { return fetch(`https://mimi.pnca.edu/f/${kind}`, {"credentials":"exclude","headers":{"accept":"text/html,application/xhtml+xml","accept-language":"en-US","cache-control":"no-cache","pragma":"no-cache"},"method":"GET"}) .then((response) => { diff --git a/data-services/html-source/mimi-server--structured/index.js b/data-services/html-source/mimi-server--structured/index.js index 6862048..c2d97c0 100644 --- a/data-services/html-source/mimi-server--structured/index.js +++ b/data-services/html-source/mimi-server--structured/index.js @@ -1,6 +1,7 @@ -const { ApolloServer, gql } = require('apollo-server'); -import resolverMap from './resolvers'; -import typeDefs from './schema'; +import apollo from 'apollo-server' +const { ApolloServer } = apollo +import resolverMap from './resolvers.js'; +import typeDefs from './schema.js'; const server = new ApolloServer({ typeDefs, resolvers: resolverMap }); diff --git a/data-services/html-source/mimi-server--structured/package-lock.json b/data-services/html-source/mimi-server--structured/package-lock.json index 2e28291..47104ea 100644 --- a/data-services/html-source/mimi-server--structured/package-lock.json +++ b/data-services/html-source/mimi-server--structured/package-lock.json @@ -1016,11 +1016,6 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, - "esm": { - "version": "3.2.25", - "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", - "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==" - }, "etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", diff --git a/data-services/html-source/mimi-server--structured/package.json b/data-services/html-source/mimi-server--structured/package.json index 0623e31..70b07b8 100644 --- a/data-services/html-source/mimi-server--structured/package.json +++ b/data-services/html-source/mimi-server--structured/package.json @@ -4,7 +4,6 @@ "description": "", "main": "index.js", "scripts": { - "start": "nodemon -r esm index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], @@ -13,11 +12,11 @@ "dependencies": { "apollo-server": "^2.11.0", "cheerio": "^1.0.0-rc.3", - "esm": "^3.2.25", "graphql": "^14.6.0", "node-fetch": "^2.6.0" }, "devDependencies": { "nodemon": "^2.0.2" - } + }, + "type": "module" } diff --git a/data-services/html-source/mimi-server--structured/resolvers.js b/data-services/html-source/mimi-server--structured/resolvers.js index 34cc191..cacfd8c 100644 --- a/data-services/html-source/mimi-server--structured/resolvers.js +++ b/data-services/html-source/mimi-server--structured/resolvers.js @@ -1,4 +1,4 @@ -import { getCollections } from './collections' +import { getCollections } from './collections.js' const resolverMap = { Query: { collections: async(_, args) => { diff --git a/data-services/html-source/mimi-server--structured/schema.js b/data-services/html-source/mimi-server--structured/schema.js index 0f74e0d..c6f2a64 100644 --- a/data-services/html-source/mimi-server--structured/schema.js +++ b/data-services/html-source/mimi-server--structured/schema.js @@ -1,4 +1,6 @@ -const { gql } = require('apollo-server'); +import apollo from 'apollo-server' +const { gql } = apollo +//import { gql } from 'apollo-server' const typeDefs = gql` "Collection defines the queryable fields for every collection in mimi"