将 Parse Server 从 v3 升级到 v4 会触发错误“GraphQL:必须提供源”

Upgrading Parse Server from v3 to v4 triggers error `GraphQL: Must provide Source`

我在版本 3.10.x 中使用 ParseServer (https://parseplatform.org) 和附带的 GraphQL 端点。我使用 apollo-link 从我的云代码中进行一些查询,因此安装了 graphql 模块(此外还有使用 apollo-serverparse-server 的依赖项)。我已经指定了 GraphQL 依赖项的版本以匹配 parse-server (v14.5.8).

使用的版本

在此配置中一切正常。

我现在将 parse-server 升级到最新版本 4.3.x,并更新 graphql 以继续匹配 parse-server 使用的版本:v15 .1.0.

服务器现在在启动时崩溃并出现错误:Must define Source. Received undefined.

我检查了错误发生时加载的graphql模块:./node_modules/graphql in version v15.1.0.

有没有人知道这个错误以及修复它的方法?

如果需要更多详细信息,请询问!

谢谢,

珀西瓦尔


编辑#1

Parse Server 由 throng 在集群中启动。

解析服务器初始化

const restAPI = new ParseServer(config)
const graphQL = new ParseGraphQLServer(restAPI, {
    graphQLPath: process.env.GRAPHQL_MOUNT || "/graphql",
    playgroundPath: "/playground",
})

// Serve the Parse API on the /parse URL prefix
app.use(process.env.PARSE_MOUNT, restAPI.app)
graphQL.applyGraphQL(app)

解析服务器配置

{
        appName: process.env.PARSE_APP_NAME,
        databaseURI: process.env.DATABASE_URI,
        databaseOptions: {
            maxTimeMS: Number(process.env.DB_QUERY_MAX_TIME) || 30000,
        },
        cloud: `${__dirname}${cloudCode}`,
        appId: process.env.PARSE_APP_ID,
        masterKey: process.env.PARSE_MASTER_KEY,
        clientKey: process.env.PARSE_CLIENT_KEY,
        javascriptKey: process.env.PARSE_JAVASCRIPT_KEY,
        restAPIKey: process.env.PARSE_REST_KEY,
        serverURL: serverURL,
        publicServerURL: serverURL,
        allowClientClassCreation: process.env.ALLOW_CLIENT_CLASS_CREATION === 'true',
        filesAdapter: new S3Adapter(
            process.env.S3_BUCKET, {
                bucketPrefix: process.env.S3_BUCKET_PREFIX,
                directAccess: true
            }),
        verifyUserEmails: false,
        emailAdapter: MailAdapter(),
        cacheAdapter: process.env.REDIS_PARSE_CACHE_URL
            ? new RedisCacheAdapter({ url: process.env.REDIS_PARSE_CACHE_URL })
            : null,
        liveQuery: {
            classNames: ["SomeClass"],
            redisURL: process.env.REDIS_LIVE_QUERIES_SERVER_URL
        },
    }

完成错误堆栈

$ heroku local web
[OKAY] Loaded ENV .env File as KEY=VALUE Format
10:45:21 web.1   |  > pinpo-parse-server@4.2.9 start:dyno:web /Users/percypyan/Developer/projects/pinpo/pinpo-parse-server
10:45:21 web.1   |  > npm run start:process:${WEB_PROCESS_NAME}
10:45:22 web.1   |  > pinpo-parse-server@4.2.9 start:process:parse-server /Users/percypyan/Developer/projects/pinpo/pinpo-parse-server
10:45:22 web.1   |  > node --optimize_for_size --gc_interval=100 lib/apps/parse-server
10:45:24 web.1   |  Error: Must provide Source. Received: undefined.
10:45:24 web.1   |      at devAssert (/Users/percypyan/Developer/projects/pinpo/pinpo-parse-server/node_modules/graphql/jsutils/devAssert.js:12:11)
10:45:24 web.1   |      at new Parser (/Users/percypyan/Developer/projects/pinpo/pinpo-parse-server/node_modules/graphql/language/parser.js:80:67)
10:45:24 web.1   |      at Object.parse (/Users/percypyan/Developer/projects/pinpo/pinpo-parse-server/node_modules/graphql/language/parser.js:35:16)
10:45:24 web.1   |      at Object.<anonymous> (/Users/percypyan/Developer/projects/pinpo/pinpo-parse-server/node_modules/graphql-tools/dist/stitching/introspectSchema.js:39:42)
10:45:24 web.1   |      at Module._compile (internal/modules/cjs/loader.js:759:30)
10:45:24 web.1   |      at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
10:45:24 web.1   |      at Module.load (internal/modules/cjs/loader.js:628:32)
10:45:24 web.1   |      at Function.Module._load (internal/modules/cjs/loader.js:555:12)
10:45:24 web.1   |      at Function.wrappedLoad [as _load] (/Users/percypyan/Developer/projects/pinpo/pinpo-parse-server/node_modules/newrelic/lib/shimmer.js:481:24)
10:45:24 web.1   |      at Module.require (internal/modules/cjs/loader.js:666:19)
10:45:24 web.1   |  npm
10:45:24 web.1   |   ERR! code ELIFECYCLE
10:45:24 web.1   |  npm ERR! errno 1
10:45:24 web.1   |  npm
10:45:24 web.1   |   ERR! pinpo-parse-server@4.2.9 start:process:parse-server: `node --optimize_for_size --gc_interval=100 lib/apps/parse-server`
10:45:24 web.1   |  npm ERR! Exit status 1
10:45:24 web.1   |  npm ERR!
10:45:24 web.1   |  npm ERR! Failed at the pinpo-parse-server@4.2.9 start:process:parse-server script.
10:45:24 web.1   |  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:45:24 web.1   |  npm ERR! A complete log of this run can be found in:
10:45:24 web.1   |  npm ERR!     /Users/percypyan/.npm/_logs/2020-09-09T08_45_24_589Z-debug.log
10:45:24 web.1   |  npm
10:45:24 web.1   |   ERR! code ELIFECYCLE
10:45:24 web.1   |  npm ERR! errno 1
10:45:24 web.1   |  npm 
10:45:24 web.1   |  ERR! pinpo-parse-server@4.2.9 start:dyno:web: `npm run start:process:${WEB_PROCESS_NAME}`
10:45:24 web.1   |  npm ERR! Exit status 1
10:45:24 web.1   |  npm ERR! 
10:45:24 web.1   |  npm
10:45:24 web.1   |   ERR! Failed at the pinpo-parse-server@4.2.9 start:dyno:web script.
10:45:24 web.1   |  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:45:24 web.1   |  npm ERR! A complete log of this run can be found in:
10:45:24 web.1   |  npm ERR!     /Users/percypyan/.npm/_logs/2020-09-09T08_45_24_655Z-debug.log
[DONE] Killing all processes with signal  SIGINT
10:45:24 web.1   Exited with exit code null

几周后,在没有进一步研究的情况下,有人建议我尝试使用 npm 而不是 yarn。所以我试过了,整个过程又恢复正常了。运行。

问题出在锁定文件中:删除后,即使用 yarn 恢复,问题也已解决。

因此,如果您遇到这种情况,请尝试删除 node_modules 文件夹和锁定文件,然后 re-run yarnnpm install。这应该可以解决问题。

Parse 社区论坛:https://community.parseplatform.org/t/parse-4-2-startup-error-must-provide-source-received-undefined/278/11

感谢 Parse 核心贡献者 davimacedo 帮助我解决了这个问题!