Example #1
0
import { WebApp } from "meteor/webapp";

const { ApolloServer, gql } = require('apollo-server-express');

// Construct a schema, using GraphQL schema language
const typeDefs = gql`
  type Query {
    hello: String
  }
`;

// Provide resolver functions for your schema fields
const resolvers = {
  Query: {
    hello: () => 'Hello world!',
  },
};

const server = new ApolloServer({ typeDefs, resolvers });

server.applyMiddleware({ app: WebApp.connectHandlers });
Example #2
0
  Subscription: {
    organization: {
      subscribe: (_, args, ctx, info) => {
        return ctx.db.subscription.organization({}, info)
      },
    },
  },
}*/
//const jwtCheck = jwt({ secret: process.env.JWT_SECRET }); // change out your secret for each environment
//app.use(path, jwtCheck);

const server = new ApolloServer({
  schema: ultimateSchema,
  subscriptions: "/subscriptions",
  cors: true,
  context: async({ req, res }) => ({
    ...req,
    db,
    //mailer
  })
});
server.applyMiddleware({
  app, 
  //  bodyParserConfig:true,
  cors: true
});
/*

app.listen({ port: 4000 }, () => {
  console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`);
});
*/