I am trying to create an apollo graphql mutation which can insert multiple rows into DB. This is my schema structure:
export default typeDefs = [`
type OptionDataObject {
id: Int,
UserID: Int,
TypeID: Int,
Value: Int
}
type OptionData {
id: Int,
UserID: Int,
TypeID: Int,
Value: Int
}
addOptionData(listOfOptionData: [OptionDataObject]): [OptionData]
type Query {
getOptionData(UserID: Int): [OptionData]
}
schema {
query: Query
mutation: Mutation
}
`];
My corresponding resolver:
export default resolver = {
Query: {
var UserID = parseInt(args.UserID);
if(UserID) {
return OptionData.findAll({
where: args
})
}
},
Mutation: {
addOptionData(_, args) {
return OptionData.createMany(args.listOfOptionData);
}
}
}
The problem here is that I already have findAll defined for returning multiple queries as a list, but there is no createMany method. Do I need to define it? In the networkInterface?
I am not able to find any documentation online for multiple row inserts and updates. Any tips would be greatly helpful.
Thanks!