Welcome to the Clothestation! This is an e-commerce platform, which can be used in many ways. Here it is used as a Skating Clothes Apparel. We built this project to help any business to sell and display their project in a great and polished UI. This project is our first MERN Full Stack Application built from scratch.
first, the ".populate('products') is trying to populate a "product field of the User schema.
const typeDefs = gql`
user that takes id, username, email, password and products in an array
type User {
_id: ID!
username: String!
email: String!
cartCount: Int! #items in cart at the time
cart: [CartItem]!
}
how we have our user schema does not have a "products" field.
there's two changes that need to be done:
change return User.findOne({ _id: context.user._id }).populate("products")to fit our user schema/model.
change the QUERY_ME query to correspond to how you want the user schema to return
export const QUERY_ME = gql`
query me {
me {
_id
username
email
}
}
`;
the type definitions and resolvers seem to be flawed
first, the ".populate('products') is trying to populate a "product field of the User schema.
how we have our user schema does not have a "products" field.
there's two changes that need to be done:
return User.findOne({ _id: context.user._id }).populate("products")
to fit our user schema/model.change the QUERY_ME query to correspond to how you want the user schema to return