Skip to content

Instantly share code, notes, and snippets.

@ngohungphuc
Created August 2, 2019 08:57
Show Gist options
  • Save ngohungphuc/5ad8acafa2ada59f08c956a7939921d6 to your computer and use it in GitHub Desktop.
Save ngohungphuc/5ad8acafa2ada59f08c956a7939921d6 to your computer and use it in GitHub Desktop.
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