Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuck0523/f5c378fff162766e3831472dcad80c8b to your computer and use it in GitHub Desktop.
Save chuck0523/f5c378fff162766e3831472dcad80c8b to your computer and use it in GitHub Desktop.
// ↓を修正して、titleフィールドにデフォルト値を設定する。
// https://gist.github.com/chuck0523/da775661c6efd666d912fb00298a1a12
// Post type
const Post = new GraphQLObjectType({
name: "Post",
description: "This represents a Post",
fields: () => ({
_id: {type: new GraphQLNonNull(GraphQLString)},
title: {
type: new GraphQLNonNull(GraphQLString),
// resolveには、PostsList(Array)の1要素(=Post)が渡ってくる。
resolve: function(post) {
return post.title || "Does not exist"
}
},
content: {type: GraphQLString}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment