apollographql / meteor-integration

🚀 meteor add apollo
http://dev.apollodata.com/core/meteor.html
108 stars 45 forks source link

SyntaxError: Use of const in strict mode #40

Closed elie222 closed 8 years ago

elie222 commented 8 years ago

I get this error when adding graphql to my Meteor server code:

/.../...app/.meteor/local/build/programs/server/packages/modules.js:55907
W20160929-19:06:56.052(3)? (STDERR) const graphql_1 = require('graphql');
W20160929-19:06:56.053(3)? (STDERR) ^^^^^
W20160929-19:06:56.054(3)? (STDERR) SyntaxError: Use of const in strict mode.

This is what I used to install Apollo:

meteor add apollo
meteor npm install --save apollo-client apollo-server express graphql graphql-tools body-parser

This is the code I've added:

import { createApolloServer } from 'meteor/apollo';
import { makeExecutableSchema, addMockFunctionsToSchema } from 'graphql-tools';

const typeDefs = [`
type Email {
  address: String
  verified: Boolean
}
type User {
  emails: [Email]
  username: String
  randomString: String
}
type Query {
  user(id: String!): User
}
schema {
  query: Query
}
`];

const resolvers = {
  Query: {
    async user(root, args, context) {
      // Only return the current user, for security
      if (context.userId === args.id) {
        return await Meteor.users.findOne(context.userId);
      }
    },
  },
  User: {
    emails: ({emails}) => emails,
    randomString: () => Meteor.Random.id(),
  }
}

const schema = makeExecutableSchema({
  typeDefs,
  resolvers
});

createApolloServer({
    schema,
});

I'm on Meteor 1.3.3.1.

elie222 commented 8 years ago

Just realised this issue is here: https://github.com/apollostack/apollo-server/issues/99

Apollo isn't supported on my version of Meteor.