Created
August 2, 2019 08:57
-
-
Save ngohungphuc/5ad8acafa2ada59f08c956a7939921d6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public class PostType : ObjectGraphType<Post> | |
{ | |
public PostType(Repository repository) | |
{ | |
Field(x => x.Id); | |
Field(x => x.Title); | |
Field(x => x.Body); | |
Field(x => x.UserId); | |
Field<ListGraphType<CommentType>, IEnumerable<Comment>>().Name("Comment") | |
.ResolveAsync(ctx => | |
{ | |
return repository.GetCommentByPostId(ctx.Source.Id); | |
}); | |
} | |
} | |
public class CommentType : ObjectGraphType<Comment> | |
{ | |
public CommentType() | |
{ | |
Field(x => x.Id); | |
Field(x => x.Email); | |
Field(x => x.Body); | |
Field(x => x.Name); | |
Field(x => x.PostId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment