Created
June 23, 2016 21:54
-
-
Save chuck0523/f5c378fff162766e3831472dcad80c8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ↓を修正して、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