Skip to content

Cannot access Rich Text field with Macro via GraphQL #73

@rangler2

Description

@rangler2

Hi,

Just raising this on the off chance that someone has already fixed this... Am running a customised version of the Umbraco 7 version of GraphQL based upon the 0.1.0 version found on nuget which I think was from the master branch..

If I add a simple macro (with no parameters, using a .cshtml that just outputs some text) into a rich text editor and then try to retrieve this via GraphQL then the value is null and following error is included in the response:

image

If I attach the debugger then it throws on this line because it can't get the Value -

: resolver.Resolve(publishedPropertyType, publishedProperty.Value);

The exception is -

System.InvalidOperationException
  HResult=0x80131509
  Message=Cannot render a macro when there is no current PublishedContentRequest.
  Source=umbraco
  StackTrace:
   at Umbraco.Web.UmbracoComponentRenderer.RenderMacro(String alias, IDictionary`2 parameters)
   at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.<>c__DisplayClass0_1.<RenderRteMacros>b__1(String macroAlias, Dictionary`2 macroAttributes)
   at Umbraco.Core.Macros.MacroTagParser.ParseMacros(String text, Action`1 textFoundCallback, Action`2 macroFoundCallback)
   at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.RenderRteMacros(String source, Boolean preview)
   at Umbraco.Web.PropertyEditors.ValueConverters.RteMacroRenderingValueConverter.ConvertDataToSource(PublishedPropertyType propertyType, Object source, Boolean preview)
   at Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedProperty.get_Value()
   at Our.Umbraco.GraphQL.Types.ComplexGraphTypeOfIPublishedContentExtensions.<>c__DisplayClass2_1.<AddUmbracoContentPropeties>b__0(ResolveFieldContext`1 context) in C:\working_git\my-navy-umbraco\Our.Umbraco.GraphQL\Types\ComplexGraphTypeOfIPublishedContentExtensions.cs:line 115
   at GraphQL.Resolvers.FuncFieldResolver`2.GraphQL.Resolvers.IFieldResolver.Resolve(ResolveFieldContext context)
   at GraphQL.Instrumentation.MiddlewareResolver.Resolve(ResolveFieldContext context)
   at GraphQL.Resolvers.FuncFieldResolver`1.GraphQL.Resolvers.IFieldResolver.Resolve(ResolveFieldContext context)
   at GraphQL.Execution.ExecutionStrategy.<ExecuteNodeAsync>d__7.MoveNext()

I am now trying to work out how to artificially add an Umbraco Context into this class but raising in case someone has solved this previously , and if not I can update if/when I figure it out.....

Thanks,
Andy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions