Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Must provide Source. Received: undefined after upgrade to graphql@15.0 #2503

Closed
Fi1osof opened this issue Apr 2, 2020 · 24 comments
Closed

Comments

@Fi1osof
Copy link

Fi1osof commented Apr 2, 2020

Title.

Downgrade to graphql@14.6.0 solve problem.

@ssypi
Copy link

ssypi commented Apr 4, 2020

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)

@yaacovCR
Copy link
Contributor

yaacovCR commented Apr 5, 2020

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

Which version are you using?

@ssypi
Copy link

ssypi commented Apr 5, 2020

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’ll try latest stable tomorrow.

@mike-marcacci
Copy link
Contributor

mike-marcacci commented Apr 5, 2020

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.

@ssypi
Copy link

ssypi commented Apr 5, 2020

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’ll 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.

@yaacovCR
Copy link
Contributor

yaacovCR commented Apr 5, 2020

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

@ssypi
Copy link

ssypi commented Apr 5, 2020

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": "graphql-tools@5.0.0-rc.1",
"version": "5.0.0-rc.1"

@yaacovCR
Copy link
Contributor

yaacovCR commented Apr 5, 2020

Ahah, makes sense now, thanks!

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

@IvanGoncharov
Copy link
Member

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

@damiangreen
Copy link

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?

@yaacovCR
Copy link
Contributor

yaacovCR commented Jun 2, 2020

Does @mike-marcacci comment above give and additional info: #2503 (comment)

@damiangreen
Copy link

I don't have multiple graphql versions

@jean9696
Copy link

jean9696 commented Jun 3, 2020

I don't have multiple graphql versions

Same here 😕

@yaacovCR
Copy link
Contributor

yaacovCR commented Jun 3, 2020

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.

@damiangreen
Copy link

ok i raised an issue there

@ahelord
Copy link

ahelord commented Jun 4, 2020

this repo example fail Apollo federation migrate example

@a7ul
Copy link

a7ul commented Jul 24, 2020

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

@zenz
Copy link

zenz commented Sep 2, 2020

@a7ul Thanks! your solution works for me!

IvanGoncharov added a commit to IvanGoncharov/graphql-js that referenced this issue Sep 3, 2020
IvanGoncharov added a commit to IvanGoncharov/graphql-js that referenced this issue Sep 3, 2020
@himharsh1997
Copy link

thanks man it worked.

@VukDukic
Copy link

VukDukic commented Feb 9, 2021

I ran npm audit fix --force to fix couple of other modules and that did the trick for graphql module issue. However, something else broker. It seems that I am not able to run gatsby-source-contentful@4.5.0 with gatsby-plugin-mdx. Back to the drawing board....

@pflugs30
Copy link

pflugs30 commented Apr 3, 2021

For anyone who happens to reach this thread from Googling and is using serverless-appsync-simulator for a local AppSync environment, I'd like to post my solution. I was getting this same error when trying to test my production code locally. It turned out that though I was sending the localhost url for my local GraphQL endpoint, I was also trying to send a fully authenticated request header. Rather, I needed to use a hardcoded header such as this:
Authorization:AWS4-HMAC-SHA256 IAMAuthorized

Once I used this Authentication header instead of a fully signed V4 request, my POST requests went through successfully. Cheers!

@BigBrosh
Copy link

BigBrosh commented May 1, 2021

Body must be a string. Received: undefined
I've received this error after upgrading to graphql v15.5.0
This issue was resolved after I've upgraded graphql-tools to ^4.0.7 version

@IvanGoncharov can this solution be mentioned somewhere in documentation? maybe some section about upgrading to v15?
coz I couldn't google this issue and I've found this thread only after checking pr for Source
I'm not the first person who receives this error after upgrading graphql so would be nice to have it somewhere

@AlvSovereign
Copy link

Installing the most recent version of graphql-tools fixed this error for me.

@narajaon
Copy link

Fixed my issue by updating merge-graphql-schemas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests