How to add Graghql to Parse server example

Hi, I am using this example right now

However, when I tried to add Graghql support to index.js, it did not work.

The code I added to index.js is similar to this:
const express = require(‘express’);
const { default: ParseServer, ParseGraphQLServer } = require(‘parse-server’);

const app = express();

const parseServer = new ParseServer({
  databaseURI: 'mongodb://localhost:27017/test',
  appId: 'APPLICATION_ID',
  masterKey: 'MASTER_KEY',
  serverURL: 'http://localhost:1337/parse',
  publicServerURL: 'http://localhost:1337/parse'
});

const parseGraphQLServer = new ParseGraphQLServer(
  parseServer,
  {
    graphQLPath: '/graphql',
    playgroundPath: '/playground'
  }
);

app.use('/parse', parseServer.app); // (Optional) Mounts the REST API
parseGraphQLServer.applyGraphQL(app); // Mounts the GraphQL API
parseGraphQLServer.applyPlayground(app); // (Optional) Mounts the GraphQL Playground - do NOT use in Production

app.listen(1337, function() {
  console.log('REST API running on http://localhost:1337/parse');
  console.log('GraphQL API running on http://localhost:1337/graphql');
  console.log('GraphQL Playground running on http://localhost:1337/playground');
});

But it does not work. Could anyone create a working Graghql example based on the above example link? Thanks

Also, I see that one can start parse server this way:
$ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test --publicServerURL http://localhost:1337/parse --mountGraphQL --mountPlayground

But, when you use “npm start” to start the parse server example, how do I supply --mountGraphQL --mountPlayground parameters?

The code looks in the right direction. Why do you say it does not work? What is the problem that you are facing?

I refactored my code. Now it is working. Thanks

I am wondering that: are you some good examples of apps that use Graghql on top of the Parse server? Could someone point out some examples? Thanks

Do you mean demo examples for templates? Or do you want to know real production apps using the GraphQL API?

I want to see demo examples for templates, but I also want to see real production apps if they are open-source. Do you know any? Thanks

You can find some examples in the link below: Back4App · GitHub

1 Like