Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const Mutation = new GraphQLObjectType({
name: "BlogMutaions",
description: "Mutaions of our blog",
fields: () => ({
createPost: {
type: Post,
args: {
title: {type: new GraphQLNonNull(GraphQLString)},
content: {type: new GraphQLNonNull(GraphQLString)}
},
resolve: function(source, args) {
let post = Object.assign({}, args)
// id生成
post._id = `${Date.now()}::${Math.ceil(Math.random() * 9999999)}`
// 著者付与
post.auther = "arunoda"
// データストアにpostを追加
PostsList.push(post)
// 新規作成したpostを返す
return post
}
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment