Just upgraded from 2.13.0 to 2.14.0 and got the following error:
Error: Cannot find module 'apollo-server'
which is thrown because I use the apollo-server-lambda one. Rolling back for now but I'm sure it's not a complicated thing to fix.
Thanks for reporting @antikvarBE
I don't think any dependencies changed with this release so I'm not immediately sure what would cause this. Can you share a code sample so I can try to reproduce this?
Hey @johnymontana , of course. If that can help, here's an idea of how I initialise my Apollo Server:
import 'source-map-support/register';
import {
ApolloServer,
makeExecutableSchema,
mergeSchemas
} from 'apollo-server-lambda';
import { makeAugmentedSchema } from 'neo4j-graphql-js';
import driver from './data-sources/knowledge-graph/driver';
// import a bunch of typeDefs, resolvers, etc.
const firstSchema = makeAugmentedSchema({
typeDefs: firstTypeDefs
});
const otherSchema = makeExecutableSchema({
typeDefs: otherTypeDefs,
resolvers: otherResolvers
});
const yetAnotherSchema = makeExecutableSchema({
typeDefs: yetAnotherSchemaTypeDefs,
resolvers: yetAnotherSchemaResolvers
});
// some more schema creations
const schema = mergeSchemas({
schemas: [
// all of the schemas created above
]
});
const server = new ApolloServer({
schema: schema,
context: ({ event, context }) => ({
headers: event.headers,
functionName: context.functionName,
event,
context,
driver
}),
dataSources: () => {
return {
firstAPI: new FirstAPI(),
secondAPI: new SecondAPI()
};
},
// Some Apollo Engine settings to push/pull schema definitions and stats
engine: {
apiKey: 'some-gibberish',
schemaTag: process.env.NODE_ENV
}
});
export const graphqlHandler = server.createHandler({
cors: { origin: '*', credentials: true }
});
had the same error on upgrading to 2.14.0
i did yarn add apollo-server to fix it.
I think it has something to do with overlapping dependency between
import {ApolloServer} from 'apollo-server-express' and 'apollo-server'
"dependencies": {
"apollo-cache-inmemory": "^1.6.5",
"apollo-client": "^2.6.8",
"apollo-link-http": "^1.5.17",
"apollo-server": "^2.12.0",
"apollo-server-express": "^2.12.0",
...
@pmualaba, I didn't install any additional packages for two reasons:
Looking at your package.json excerpt, it feels like apollo-server and apollo-server-express shouldn't be there at the same time. Looking at my yarn.lock file, I can see apollo-server-lambda needs apollo-server-core to function and not apollo-server. No peerDependencies there either. I would imagine same happens in apollo-server-express.
Either way: how's neo4j-graphql-js involved at all?
the way i see it is you have a run-time dependency on the apollo server package, and its not declared in the package.json as a dependency...
the way i see it is you have a run-time dependency on the apollo server package, and its not declared in the package.json as a dependency...
I'd think so too but the official docs don't want you to do that. Plus it is working fine without this dependency in an isolated lambda environment (so no runtime dependencies there). Plus it doesn't complain about any peerDependencies as other modules normally do during upgrades and no other package upgrades besides neo4j-graphql-js cause this to happen.
I know it is very silly that something presumably completely unrelated could cause this error but I'm just stating the facts.
I just encountered the same issue by just upgrading to 2.14.0. I didn't try any federation yet. BTW, I do run on apollo-server-express.
I also have this error. apollo-server is required by federation.js. This is not found if using apollo-server-express or apollo-server-lambda etc.
internal/modules/cjs/loader.js:985
throw err;
^
Error: Cannot find module 'apollo-server'
Require stack:
- /workspace/node_modules/neo4j-graphql-js/dist/federation.js
- /workspace/node_modules/neo4j-graphql-js/dist/augment/resolvers.js
- /workspace/node_modules/neo4j-graphql-js/dist/augment/augment.js
- /workspace/node_modules/neo4j-graphql-js/dist/augment/fields.js
- /workspace/node_modules/neo4j-graphql-js/dist/augment/directives.js
- /workspace/node_modules/neo4j-graphql-js/dist/augment/types/types.js
- /workspace/node_modules/neo4j-graphql-js/dist/utils.js
- /workspace/node_modules/neo4j-graphql-js/dist/translate.js
- /workspace/node_modules/neo4j-graphql-js/dist/index.js
- /workspace/dist/tilt-graphql/schema.js
- /workspace/dist/tilt-graphql/index.js
- /workspace/dist/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/workspace/node_modules/neo4j-graphql-js/dist/federation.js:49:21)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/workspace/node_modules/neo4j-graphql-js/dist/federation.js',
'/workspace/node_modules/neo4j-graphql-js/dist/augment/resolvers.js',
'/workspace/node_modules/neo4j-graphql-js/dist/augment/augment.js',
'/workspace/node_modules/neo4j-graphql-js/dist/augment/fields.js',
'/workspace/node_modules/neo4j-graphql-js/dist/augment/directives.js',
'/workspace/node_modules/neo4j-graphql-js/dist/augment/types/types.js',
'/workspace/node_modules/neo4j-graphql-js/dist/utils.js',
'/workspace/node_modules/neo4j-graphql-js/dist/translate.js',
'/workspace/node_modules/neo4j-graphql-js/dist/index.js',
'/workspace/dist/tilt-graphql/schema.js',
'/workspace/dist/tilt-graphql/index.js',
'/workspace/dist/index.js'
]
}
This is now fixed in v2.14.2
Yes, this does work now. Thank you, @wworrall!
Most helpful comment
I also have this error.
apollo-serveris required byfederation.js. This is not found if usingapollo-server-expressorapollo-server-lambdaetc.