Graphql-js: Error: Must provide Source. Received: undefined after upgrade to [email protected]

Created on 2 Apr 2020  路  18Comments  路  Source: graphql/graphql-js

Title.

Downgrade to [email protected] solve problem.

Most helpful comment

I don't have multiple graphql versions

All 18 comments

Same here, it's possible the problem is in graphql-tools instead though as it seems to begin from there.

Error: Must provide Source. Received: undefined.
    at devAssert (node_modules/graphql/jsutils/devAssert.js:13:11)
    at new Parser (node_modules/graphql/language/parser.js:82:67)
    at Object.parse (node_modules/graphql/language/parser.js:35:16)
    at Object.<anonymous> (node_modules/graphql-tools/dist/stitching/introspectSchema.js:39:42)

at graphql-tools/dist/stitching/introspectSchema.js:39:42

var graphql_1 = require("graphql");
var linkToFetcher_1 = require("./linkToFetcher");
var parsedIntrospectionQuery = graphql_1.parse(graphql_1.introspectionQuery);


It seems that the bolded part graphql_1.introspectionQuery is undefined which then causes the error at node_modules/graphql/language/parser.js:82:67)

If I change that line from graphql_1.introspectionQuery -> graphql_1.getIntrospectionQuery() it seems to work.


EDIT: Ah, it's deprecated, mentioned in the changelogs:
#2124 Remove deprecated 'introspectionQuery' constant (@IvanGoncharov)

Should be fixed in graphql-tools v4.0.7. (https://github.com/apollographql/graphql-tools/blob/master/CHANGELOG.md)

Which version are you using?

I

Should be fixed in graphql-tools v4.0.7. (https://github.com/apollographql/graphql-tools/blob/master/CHANGELOG.md)

Which version are you using?

I was on latest v5 alpha, I鈥檒l try latest stable tomorrow.

This is almost certainly due to the existence of multiple different versions of graphql in your dependency tree. You can look for this by running either:

# using yarn
yarn why graphql

# using npm
npm ls graphql

While GraphQL 15 _is_ a major change, you may find that the libraries you use that have a stated dependency of 14 will still work with the new version. If this is the case, you can force the use of version 15 everywhere using yarn's resolutions or npm-force-resolutions.

However, the real solution is to make sure all libraries are updated to use the newest version of graphql.

I

Should be fixed in graphql-tools v4.0.7. (https://github.com/apollographql/graphql-tools/blob/master/CHANGELOG.md)
Which version are you using?

I was on latest v5 alpha, I鈥檒l try latest stable tomorrow.

Maybe op has a different problem, but for me at least, the problem seems to be in graphql-tools v5.0.0-alpha.2, downgrading to 4.0.7 fixed the problem.

Should definitely be fixed in graphql-tools alpha.

One thing you can try is to delete your node_modules folder and reinstall:

Of note, this path is no longer within the graphql-tools alpha version:
node_modules/graphql-tools/dist/stitching/introspectSchema.js

Having been replaced by:
node_modules/graphql-tools/dist/stitch/introspectSchema.js

Should definitely be fixed in graphql-tools alpha.

One thing you can try is to delete your node_modules folder and reinstall:

Of note, this path is no longer within the graphql-tools alpha version:
node_modules/graphql-tools/dist/stitching/introspectSchema.js

Having been replaced by:
node_modules/graphql-tools/dist/stitch/introspectSchema.js

I removed node_modules and package-lock.json several times during testing and the problem always reoccurred, but I think I found the problem.

There's a version 5.0.0-rc.1 published a year ago in NPM registry and it seems that for some reason npm was installing that version instead. I guess it thought it was newer than the 5.0.0-alpha.2. I had ^5.0.0-alpha.2 in my package.json.

This is a part of the package.json from graphql-tools that was getting installed and it seems to be the wrong version:

"_from": "graphql-tools@^5.0.0-alpha.2",
"_id": "[email protected]",
"version": "5.0.0-rc.1"

Ahah, makes sense now, thanks!

That is a very old rc, and graphql-tools has gone back to alphas prior to release of v5.

@yaacovCR Thanks investigating this issue 馃憤
It looks like nothing should be changed in graphql-js so I'm closing it.

I've bumped to the latest "graphql-tools": "^6.0.6", + "graphql": "15.0.0", and i still receive this error.
What is the resolution?

Does @mike-marcacci comment above give and additional info: https://github.com/graphql/graphql-js/issues/2503#issuecomment-609359497

I don't have multiple graphql versions

I don't have multiple graphql versions

Same here 馃槙

So far from above the problem seems to be with graphql-tools rather than graphql-js...

You might want to open an issue there with attention to version of graphql-tools. A minimal reproduction would be helpful.

ok i raised an issue there

this repo example fail Apollo federation migrate example

I had the same issue after upgrading to graphql v15

 "graphql": "^15.1.0",
 "apollo-server-express": "^2.16.0"

After reading through comments, I added

"resolutions": {
   "graphql-tools": "4.0.7"
 }

Following this, deleted my node_modules and reinstalled using yarn install

And it fixed my issue

@a7ul Thanks! your solution works for me!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thomasdingemanse picture thomasdingemanse  路  4Comments

closertb picture closertb  路  3Comments

ablbol picture ablbol  路  4Comments

galki picture galki  路  3Comments

davide-ganito picture davide-ganito  路  4Comments