Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Syntax Error with express-graphql #665

Closed
sumit298 opened this issue Jul 5, 2020 · 2 comments
Closed

Syntax Error with express-graphql #665

sumit298 opened this issue Jul 5, 2020 · 2 comments
Labels

Comments

@sumit298
Copy link

sumit298 commented Jul 5, 2020

Here I am trying to creating Graphql Schema
Code=>

`const express = require('express');

const graphqlHttp = require("express-graphql")
const { buildSchema } = require('graphql');

const app = express();

app.use(express.json());

app.use(
'/graphql',
graphqlHttp({
schema: buildSchema(`
type RootQuery {
events: [String!]!
}

    type RootMutation {
        createEvent(name: String): String
    }

    schema {
        query: RootQuery
        mutation: RootMutation
    }
`),
rootValue: {
  events: () => {
    return ['Cooking', 'Sailing', 'All-Night Coding'];
  },
  createEvent: (args) => {
    const eventName = args.name;
    return eventName;
  }
},
graphiql: true

})
);

app.listen(3000, ()=>console.log("Server up and running at Port 3000"));`

but I am getting error of

  pretty = optionsData.pretty ?? false;
                                 ^

SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:1054:16)
at Module._compile (internal/modules/cjs/loader.js:1102:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object. (C:\Users\User\Desktop\Graphql-FullStack\index.js:3:21)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)

I installed express-graphql of version 0.1.0.

Now what should I do??

@danielrearden
Copy link
Collaborator

@sumitsssss Thanks for submitting this issue. This looks like a regression on our end. We'll get it patched ASAP.

@IvanGoncharov
Copy link
Member

Fixed in 0.10.1 📦

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants