I am trying to serve an executable schema. I get the following error while using version 2.0.2. Works totally fine with version 2.0.0.
Error: Cannot find module 'core-js/modules/es7.object.entries'
at Object.<anonymous> (/home/wawhal/oss/schema-stitching-examples/multiple-remote-graphql-apis/node_modules/apollo-upload-server/lib/middleware.js:14:1)
Here is the code:
import {
makeRemoteExecutableSchema,
introspectSchema,
mergeSchemas
} from 'graphql-tools';
import { HttpLink } from 'apollo-link-http';
import { ApolloServer } from 'apollo-server';
import fetch from 'node-fetch';
// secret keys
const GITHUB_TOKEN = process.env.GITHUB_TOKEN || 'github-token';
const X_HASURA_ACCESS_KEY = process.env.X_HASURA_ACCESS_KEY || '<key>';
// graphql API metadata
const graphqlApis = [
{
uri: 'https://api.github.com/graphql',
headers: { 'Authorization': `Bearer ${GITHUB_TOKEN}` }
},
{
uri: 'https://api1.com/graphql',
headers: { 'x-hasura-access-key': X_HASURA_ACCESS_KEY }
}
];
// create executable schemas from remote GraphQL APIs
const createRemoteExecutableSchemas = async () => {
let schemas = [];
for (const api of graphqlApis) {
const link = new HttpLink({
uri: api.uri,
headers: api.headers,
fetch
});
const remoteSchema = await introspectSchema(link);
const remoteExecutableSchema = makeRemoteExecutableSchema({
schema: remoteSchema,
link
});
schemas.push(remoteExecutableSchema);
}
return schemas;
};
const createNewSchema = async () => {
const schemas = await createRemoteExecutableSchemas();
console.log(schemas);
return mergeSchemas({
schemas
});
};
const runServer = async () => {
console.log('here');
// Get newly merged schema
const schema = await createNewSchema();
// start server with the new schema
const server = new ApolloServer({
schema
});
server.listen().then(({url}) => {
console.log(`Running at ${url}`);
});
};
try {
console.log('here');
runServer();
} catch (err) {
console.error(err);
}
/label bug
official getting-started example shows the same error.
https://www.apollographql.com/docs/apollo-server/getting-started.html
I am having the same problem using apollo-server-express.
The issue seems to be caused by the peer dependency apollo-upload-server (see related issue here).
A temporary workaround : npm install core-js
This is now fixed in [email protected] (and the apollo-server-{integration} packages, like apollo-server-express) thanks to https://github.com/apollographql/apollo-server/commit/8347511db8e5f9ae6026833af17d266ec165e8dc in #1556.
Therefore, if you've previously installed core-js as a direct dependency of your application to overcome this problem (as suggested in https://github.com/apollographql/apollo-server/issues/1542#issuecomment-413790442 above), you can now npm install [email protected] (or the appropriate integration package!) and npm uninstall core-js.
Thanks for reporting this originally!
hmm npm install [email protected] fails because version unfound, it doesn't look published yet.
I assume [email protected] which has been published with [email protected] contains the fix.
@abenhamdine Sorry, you're right, I should have just said "it's fixed in latest" since the integration packages have independent versioning now to avoid bumping _all_ integrations versions when only one of the underlying integration frameworks has changed (e.g. if only express's API changed, we'd have had to confusingly bump apollo-server-hapis version too). Thanks for pointing this out!
This is still not fixed for apollo-server-koa@rc which seems to be left behind from other apollo-server integrations!
@human-a The official release of apollo-server and apollo-server-koa 2.x has come out and neither are still in the release-candidate phase. However, the rc tag still points to the last release candidate version of apollo-server-koa. I believe if you'd like to get this fix, you'd need to move to the latest tag. The rc tag will likely remain pointed to the last 2.x RC until the next series of release candidate testing begins — most likely to occur whenever apollo-server-* 2.1.x packages mature to an RC state.
That is to say, can you try with [email protected] – as of this writing, the latest/most recent version?
Awesome! thanks :)
After upgrading to 2.3.3, I got the same error again. Downgrading to 2.0.4 fixed it.
Same here 😞
Same here but with following error:
"Error: Cannot find module 'core-js/proposals/array-flat-and-flat-map"
Fixed by downgrading to 2.0.7
I'm using apollo-server-express 2.2.6 and yarn install, any idea about how to solve this? I have another project with same base code and package version and it is working!
@giovangonzalez Please update to a newer version of Apollo Server and see if the problem is still occurring. If it is, please open a new issue with a runnable reproduction, per the instructions when opening a new issue. Thanks!
Most helpful comment
A temporary workaround :
npm install core-js