Parse 4.2 startup error Must Provide Source. Received: undefined

I am upgrading from Parse Server 3.10 to 4.2 and I am getting the following error:

XXXXXXX/node_modules/graphql/jsutils/devAssert.js:13
    throw new Error(message);
    ^

Error: Must provide Source. Received: undefined.
    at devAssert (XXXXXXXXX/node_modules/graphql/jsutils/devAssert.js:13:11)
    at new Parser (XXXXXXXXX/node_modules/graphql/language/parser.js:80:67)
    at Object.parse (XXXXXXXXX/node_modules/graphql/language/parser.js:35:16)
    at Object.<anonymous> (XXXXXXXXX/node_modules/graphql-tools/dist/stitching/introspectSchema.js:39:42)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Anyone have any ideas how to fix it?

Could you please share the code that you are using to initialize the Parse Server?

Hi @davimacedo, here is the code

// Create the Parse Server API
const api = new ParseServer({
  databaseURI: databaseUri || defaultDatabaseUri,
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'XXXXXXXXXXXX',
  masterKey: process.env.MASTER_KEY || 'XXXXXXXXXXXX', // Add your master key here. Keep it secret!
  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
  allowClientClassCreation: false,
  enableAnonymousUsers: false, // default is true, we may want this.
  verifyUserEmails: true,
  publicServerURL: `${publicServerURL}${mountPath}` || 'https://api.mydomain.com/1',
  preventLoginWithUnverifiedEmail: false,
  appName: 'XXXXXXXXX',
  // sessionLength: 31536000, // 1 year, default value
  // emailVerifyTokenValidityDuration: undefined, // default
  revokeSessionOnPasswordReset: true,
  emailAdapter: PostmarkAdapter({
    apiKey: process.env.POSTMARK_API,
    fromAddress: process.env.POSTMARK_FROM_ADDRESS,
  }),
  accountLockout: {
    duration: 5, // duration policy setting determines the number of minutes that a locked-out account remains locked out before automatically becoming unlocked. Set it to a value greater than 0 and less than 100000.
    threshold: 3, // threshold policy setting determines the number of failed sign-in attempts that will cause a user account to be locked. Set it to an integer value greater than 0 and less than 1000.
  },
  customPages: {
    invalidLink: `${publicServerURL}/public/invalid.html`,
    choosePassword: `${publicServerURL}/public/change_password.html`,
    passwordResetSuccess: `${publicServerURL}/public/success.html`,
    verifyEmailSuccess: `${publicServerURL}/public/verify_email.html`,
  },
});

// Create the app and init our custom APIs
const app = coreApi.initApp(serverId);

// Serve the Parse API on the /1 URL prefix
app.use(mountPath, api);

// Final handler - Bugsnag. This handles any errors that Express catches
app.use(coreApi.bugsnagMiddleware.errorHandler);

// Start the server
const httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
  console.info(`API Server running on port ${port} for environment ${serverId}.`);
  console.info(`Connected to database: ${coreApi.utils.getSafeDbURI(databaseUri)}`);
});

// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer);

Many thanks

Are you also initializing the GraphQL server?

No, only using REST atm.

Sorry for the delay. Have you figured it out? Do you mind to try without loading the cloud code?

Hi, I’ve a similar problem.

I use GraphQL with the Parse server and have the graphql dependency installed to allow me to execute GraphQL queries from the Cloud Code.

The details of the situation are here : https://stackoverflow.com/questions/63798387/upgrading-parse-server-from-v3-to-v4-triggers-error-graphql-must-provide-sourc?noredirect=1#comment112909216_63798387

If someone have any idea to solve this situation I’ll be grateful.

Details of the yarn why graphql command:

yarn why v1.22.4
[1/4] 🤔  Why do we have the module "graphql"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "[email protected]"
info Has been hoisted to "graphql"
info Reasons this module exists
   - Specified in "dependencies"
   - Hoisted from "parse-server#graphql"
info Disk size without dependencies: "3.23MB"
info Disk size with unique dependencies: "3.23MB"
info Disk size with transitive dependencies: "3.23MB"
info Number of shared dependencies: 0
=> Found "@types/graphql-upload#[email protected]"
info This module exists because "parse-server#apollo-server-express#apollo-server-core#@types#graphql-upload" depends on it.
info Disk size without dependencies: "3.27MB"
info Disk size with unique dependencies: "3.27MB"
info Disk size with transitive dependencies: "3.27MB"
info Number of shared dependencies: 0

Same problem if you install the dependencies via npm?

No! I just tried and the server starts and seems to work as expected!
But what cause yarn to not being able to install dependencies properly?

Hum I just tried again with yarn but after removing yarn.lock file and that seems to be working too. Maybe it was just a problem with the existing lock file…

Some GraphQL related dependencies as been upgraded, it’s probably that.

Nice. I’m glad you got it working.

Yep, removing node_modules and yarn.lock allowed a successful upgrade