Skip to content

Commit

Permalink
removed need for esm, see apollographql/apollo-server#3786 for workar…
Browse files Browse the repository at this point in the history
…ound for apollo-server module issues
  • Loading branch information
derekjwilliams committed Mar 28, 2020
1 parent e52f8d5 commit 156ba13
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 19 deletions.
6 changes: 2 additions & 4 deletions data-services/html-source/mimi-server--structured/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
7 changes: 4 additions & 3 deletions data-services/html-source/mimi-server--structured/index.js
Original file line number Diff line number Diff line change
@@ -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 });

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon -r esm index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
Expand All @@ -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"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCollections } from './collections'
import { getCollections } from './collections.js'
const resolverMap = {
Query: {
collections: async(_, args) => {
Expand Down
4 changes: 3 additions & 1 deletion data-services/html-source/mimi-server--structured/schema.js
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 156ba13

Please sign in to comment.