Skip to content

schema for nest model #3

@jackypan1989

Description

@jackypan1989

I have a user <-> company relation
so I build like that

const UserSchema = new mongoose.Schema({
  company: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Company'
  }
})

after adding relation, it works with RootQuery.

However, it failed when I try to RootMutation user with companyId.
The graphql console shows that company is "GQLReference" not MongoID or String type
till I wrote

const UserSchema = new mongoose.Schema({
  company: {
    type: String,
  }
})

to make RootQuery and RootMutation available.

Did I miss anything?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions