Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Apr 24, 2020 @ 15:13
    Ismail Mayat
    0

    How to get grid property in umbraco graphql

    I have site v7 that is using umbraco graphql package. I have doctype alert which I can get using query like:

    { content {
    byUrl(url: "/alerts/test/") {
      ... on Alert {
        _contentData {
          name
        },title
        summary
      }
    }}}
    

    I have grid page and that has a doctype grid editor property that is multi node tree picker that allows picking of alerts doctype.

    My graphql query to get content of grid page works but the alert picker is blob of json.

    I have written a graph resolver looks like:

     public class AlertResolver:GraphQLValueResolver
    {
        public override Type GetGraphQLType(PublishedPropertyType propertyType)
        {
            return typeof(AlertModelType);
        }
    
        public override bool IsConverter(PublishedPropertyType propertyType)
        {
            return propertyType.PropertyEditorAlias == "alert";
        }
    }
    
    public class AlertModelType: ObjectGraphType<JToken>
    {
        public AlertModelType()
        {
            Name = "Alert";
            Field<NonNullGraphType<StringGraphType>>("title",resolve:context=>context.Source["title"]);
            Field<NonNullGraphType<StringGraphType>>("summary",resolve:context=>context.Source["summary"]);
        }
    }
    

    In the graphql api I cannot render that alert I do not see it in intellisense. Is it even possible to write a resolver for grid property?

Please Sign in or register to post replies

Write your reply to:

Draft