How to expose graphql field with different name

后端 未结 4 1498
攒了一身酷
攒了一身酷 2020-12-18 18:33

I am exploring GraphQL and would like to know if there is any way of renaming the response field for example i have a POJO with these field

class POJO {
  Lo         


        
4条回答
  •  遥遥无期
    2020-12-18 19:05

    I know this question is very old but following code is used for renaming the field:

    public class ProductReviewType: ObjectGraphType
    {
        public ProductReviewType()
        {
            Field(x => x.ProductReviewId, type: typeof(IdGraphType)).Description("some desc here");
            Field(x => x.ProductId).Description("some desc here");
            Field("reviewername", x => x.ReviewerName).Description("some desc here");            
            Field("reviewdate",x => x.ReviewDate).Description("some desc here");
            Field("emailaddress", x => x.EmailAddress).Description("some desc here");
            Field("rating", x => x.Rating).Description("some desc here");
            Field("comments",x => x.Comments).Description("some desc here");
            Field("modifieddate", x => x.ModifiedDate).Description("some desc here");
        }
    
    }
    

    In the above code, modifieddate would be the field name for property "ModifiedDate".

提交回复
热议问题