Closed jcguarinpenaranda closed 4 years ago
Can you please share how you are importing the ParseServer
and ParseGraphQLServer
vars? You should try something like this:
const { default: ParseServer, ParseGraphQLServer } = require('parse-server');
Hello @davimacedo, Thank youy so much, I confirm it's working :) Juan
Can you please share how you are importing the
ParseServer
andParseGraphQLServer
vars? You should try something like this:const { default: ParseServer, ParseGraphQLServer } = require('parse-server');
Hi @davimacedo, I got a new error after I changing the code.
2021-03-11T05:44:15.630914+00:00 app[web.1]: > node index.js
2021-03-11T05:44:15.630914+00:00 app[web.1]:
2021-03-11T05:44:18.757458+00:00 app[web.1]: /app/node_modules/express/lib/router/index.js:458
2021-03-11T05:44:18.757487+00:00 app[web.1]: throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
2021-03-11T05:44:18.757489+00:00 app[web.1]: ^
2021-03-11T05:44:18.757489+00:00 app[web.1]:
2021-03-11T05:44:18.757490+00:00 app[web.1]: TypeError: Router.use() requires a middleware function but got a Object
2021-03-11T05:44:18.757491+00:00 app[web.1]: at Function.use (/app/node_modules/express/lib/router/index.js:458:13)
2021-03-11T05:44:18.757493+00:00 app[web.1]: at Function.<anonymous> (/app/node_modules/express/lib/application.js:220:21)
2021-03-11T05:44:18.757494+00:00 app[web.1]: at Array.forEach (<anonymous>)
2021-03-11T05:44:18.757495+00:00 app[web.1]: at Function.use (/app/node_modules/express/lib/application.js:217:7)
2021-03-11T05:44:18.757495+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:47:7)
2021-03-11T05:44:18.757495+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1092:14)
2021-03-11T05:44:18.757496+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
2021-03-11T05:44:18.757496+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:972:32)
2021-03-11T05:44:18.757496+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:813:14)
2021-03-11T05:44:18.757497+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
Same problem. Cant get it running.
For those who are facing the problem:
1) const ParseServer = require('parse-server').default;
and const ParseServer = require('parse-server').ParseServer;
is different
.
2) To fix this issue, use const { default: ParseServer, ParseGraphQLServer } = require('parse-server');
. And change app.use(mountPath, api);
to app.use(mountPath, api.app);
.
To anyone who uses TypeScript, follow this import
import { ParseGraphQLServer, default as ParseServer } from 'parse-server'
import express from 'express'
const app = express()
const parseServer = new ParseServer(config) // passing configs as normal
// mounts the RESTFull API (optionals)
app.use('/parse', parseServer.app)
const parseGraphQLServer = new ParseGraphQLServer(
parseServer,
{
graphQLPath: '/graphql',
playgroundPath: '/playground'
}
)
// Mounts the GraphQL API
parseGraphQLServer.applyGraphQL(app)
// Mounts the GraphQL Playground API (optionals)
if (isDev) {
parseGraphQLServer.applyPlayground(app)
}
app.listen(1337, () => {
console.log('Server is online')
})
Issue Description
Hello,
I am getting the following error when I create the GraphQL server with express:
Steps to reproduce
The code that I wrote is the following. All I do is create a Parse server + graphQL + dashboard, as follows:
Expected Results
The GraphQL endpoint should be mounted correctly and the application should not crash.
Actual Outcome
The application crashes due to an error with the GraphQL srever
Environment Setup
Server
Database
My dependencies are: