Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I just Need to know How to Register User With a Profile Directly #1

Open
dimer191996 opened this issue Mar 18, 2021 · 3 comments
Open

Comments

@dimer191996
Copy link

No description provided.

@dletorey
Copy link
Owner

What do you mean by that?

@dimer191996
Copy link
Author

dimer191996 commented Mar 25, 2021

I tried to use your logic to connect express to apollo server but keep getting the error “CANNOT POST /”?

 const express = require("express");
    const cors = require("cors");
    const { ApolloServer, PubSub } = require("apollo-server-express");
    const mongoose = require("mongoose");
    
    const app = express();
    
    app.use(cors());
    
    const typeDefs = require("./graphql/typeDefs");
    const resolvers = require("./graphql/resolvers");
    const { MONGODB } = require("./config");
    
    const pubSub = new PubSub();
    const server = new ApolloServer({
      typeDefs,
      resolvers,
      context: ({ req }) => ({ req, pubSub }),
    });
    
    server.applyMiddleware({ app, path: "/graphql" });
    
    mongoose
      .connect(MONGODB, {
        useNewUrlParser: true,
        useCreateIndex: true,
        useUnifiedTopology: true,
      })
      .then(() => {
        console.log("connected to mongoDB");
        return app.listen({ port: 3000 });
      });
    //MongoDB connection error
    mongoose.connection.on("error", (err) => {
      console.log(err);
    });

@dletorey
Copy link
Owner

I got this all from here https://youtu.be/n1mdAPFq2Os?t=10316 try that for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants