question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError in 2.9.5

See original GitHub issue

I am experiencing TypeError in apollo-server-express@2.9.5. I’ve not had this error in previous version and I can confirm this in PR. Starting to failing the build in circleci when upgrading the apollo packages.

Below is a log.

(node:5777) UnhandledPromiseRejectionWarning: TypeError: _schema.then is not a function
    at new ApolloServerBase (/Users/dooboolab/Github/dooboolab/hackatalk-server/node_modules/apollo-server-express/node_modules/apollo-server-core/src/ApolloServer.ts:365:40)
    at new ApolloServer (/Users/dooboolab/Github/dooboolab/hackatalk-server/node_modules/apollo-server-express/src/ApolloServer.ts:88:5)
    at Object.<anonymous> (/Users/dooboolab/Github/dooboolab/hackatalk-server/src/app.ts:43:18)
    at Generator.next (<anonymous>)
    at /Users/dooboolab/Github/dooboolab/hackatalk-server/node_modules/merge-graphql-schemas/node_modules/apollo-link/node_modules/tslib/tslib.js:107:75
    at new Promise (<anonymous>)
    at __awaiter (/Users/dooboolab/Github/dooboolab/hackatalk-server/node_modules/merge-graphql-schemas/node_modules/apollo-link/node_modules/tslib/tslib.js:103:16)
    at Object.startServer (/Users/dooboolab/Github/dooboolab/hackatalk-server/src/app.ts:27:12)
    at Object.<anonymous> (/Users/dooboolab/Github/dooboolab/hackatalk-server/src/server.ts:3:1)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Module.m._compile (/Users/dooboolab/Github/dooboolab/hackatalk-server/node_modules/ts-node/src/index.ts:493:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/dooboolab/Github/dooboolab/hackatalk-server/node_modules/ts-node/src/index.ts:496:12)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
    at Object.<anonymous> (/Users/dooboolab/Github/dooboolab/hackatalk-server/node_modules/ts-node/src/bin.ts:158:12)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)

–>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
henry-youngcommented, Oct 21, 2019

Perhaps there could be better type checking and error messaging. In the offending code, apollo server assumes that if it isn’t a GraphQLSchema then it is a promise of GraphQLSchema.

// apollo-core/ApolloServer.ts - Line 365
    if (_schema instanceof GraphQLSchema) {
      const derivedData = this.generateSchemaDerivedData(_schema);
      this.schema = derivedData.schema;
      this.schemaDerivedData = Promise.resolve(derivedData);
    } else {
      this.schemaDerivedData = _schema.then(schema =>
        this.generateSchemaDerivedData(schema),
      );
    }

Potentially a fix could be to convert non-promise schemas to a promise, resolve that schema promise, then type check the schema against GraphQLSchema.

I’ve also seen other projects (e.g. class-validator) warn of multiple versions of the library in node_modules, although this case would be a concern for the graphql library.

2reactions
henry-youngcommented, Oct 18, 2019

@hyochan I was also experiencing this error. I found that this issue was caused by different npm modules using conflicting versions of graphql. My fix included using yarn resolutions to set the version of graphql that your modules will use.

Snippet from my package.json

{
  ...
  "dependencies":{
    "graphql": "^14.5.8"
    ...
  },
  "resolutions": {
    "type-graphql/**/graphql": "^14.5.8"
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

use react-modal error: Uncaught TypeError: Cannot read ...
Error is Uncaught TypeError: Cannot read property 'ReactCurrentOwner' of undefined. I tried reinstall node_modules, and npm install, update, ...
Read more >
Frequently Asked Questions — Psycopg 2.9.5 documentation
I can't compile psycopg2 : the compiler says error: libpq-fe. h: No such file or directory. What am I missing?
Read more >
“Tinymce Error!” or my screen freezes when editing ...
Currently i am using version (Version 2.9.5) i believe this is the latest version. ... kc.tools.js?ver=2.9.5:1107 TypeError: Cannot read property 'get' of ...
Read more >
Icinga Web 2 Changelog
What's New in Version 2.9.5¶ ... Bug 9330: Uncaught TypeError: Cannot read property 'id' of undefined when deleting comments or downtimes via their ......
Read more >
Red Hat Quay Release Notes
Version 2.9.5 ... Remove setup and superuser routes when SUPER_USERS is not enabled; TypeError in Gitlab trigger when user not found. Regressed:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found