How to define type for object in graphql schema?

How to define type for object in graphql schema?


-2

I have todo’s mongo schema like this:

const todoSchema = new Schema(
  {
    userId: { type: String, required: true },
    title: { type: String, required: true },
    due_date: {
      date: { type: Number },
      month: { type: Number },
      year: { type: Number },
      hours: { type: Number },
      minute: { type: Number },
    },
    status: { type: String, required: true},
  },
  { timestamps: true }
);

I wanna make graphql schema so I did like this:

const Todo = new GraphQLObjectType({
  name: "Todo",
  fields: () => ({
    _id: { type: GraphQLID },
    userId: { type: GraphQLString },
    title: { type: GraphQLString },
    due_date: { type: GraphQLString },
    status: { type: GraphQLString },
  })
});

So my question is what is the correct type for due date? In mongo I defined it as an object and how can I define the due_date as an object in graphql schema?


Load 6 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *