public DynamicContentTypeBuilder(IHttpContextAccessor httpContextAccessor,
                                         IOptions <GraphQLContentOptions> contentOptionsAccessor,
                                         IStringLocalizer <DynamicContentTypeBuilder> localizer)
        {
            _httpContextAccessor = httpContextAccessor;
            _contentOptions      = contentOptionsAccessor.Value;

            T = localizer;
        }
        public DynamicContentTypeBuilder(IHttpContextAccessor httpContextAccessor,
                                         IOptions <GraphQLContentOptions> contentOptionsAccessor,
                                         IStringLocalizer <DynamicContentTypeBuilder> localizer)
        {
            _httpContextAccessor = httpContextAccessor;
            _contentOptions      = contentOptionsAccessor.Value;
            _dynamicPartFields   = new Dictionary <string, FieldType>();

            S = localizer;
        }
        public ContentItemType(IOptions <GraphQLContentOptions> optionsAccessor)
        {
            _options = optionsAccessor.Value;

            Name = "ContentItemType";

            Field(ci => ci.ContentItemId).Description("Content item id");
            Field(ci => ci.ContentItemVersionId).Description("The content item version id");
            Field(ci => ci.ContentType).Description("Type of content");
            Field(ci => ci.DisplayText).Description("The display text of the content item");
            Field(ci => ci.Published).Description("Is the published version");
            Field(ci => ci.Latest).Description("Is the latest version");
            Field <DateTimeGraphType>("modifiedUtc", resolve: ci => ci.Source.ModifiedUtc, description: "The date and time of modification");
            Field <DateTimeGraphType>("publishedUtc", resolve: ci => ci.Source.PublishedUtc, description: "The date and time of publication");
            Field <DateTimeGraphType>("createdUtc", resolve: ci => ci.Source.CreatedUtc, description: "The date and time of creation");
            Field(ci => ci.Owner).Description("The owner of the content item");
            Field(ci => ci.Author).Description("The author of the content item");

            Field <StringGraphType, string>()
            .Name("render")
            .ResolveLockedAsync(async context =>
            {
                var userContext     = (GraphQLContext)context.UserContext;
                var serviceProvider = userContext.ServiceProvider;

                // Build shape
                var displayManager      = serviceProvider.GetRequiredService <IContentItemDisplayManager>();
                var updateModelAccessor = serviceProvider.GetRequiredService <IUpdateModelAccessor>();
                var model = await displayManager.BuildDisplayAsync(context.Source, updateModelAccessor.ModelUpdater);

                var displayHelper = serviceProvider.GetRequiredService <IDisplayHelper>();
                var htmlEncoder   = serviceProvider.GetRequiredService <HtmlEncoder>();

                using (var sb = StringBuilderPool.GetInstance())
                {
                    using (var sw = new StringWriter(sb.Builder))
                    {
                        var htmlContent = await displayHelper.ShapeExecuteAsync(model);
                        htmlContent.WriteTo(sw, htmlEncoder);

                        await sw.FlushAsync();
                        return(sw.ToString());
                    }
                }
            });

            Interface <ContentItemInterface>();

            IsTypeOf = IsContentType;
        }
        public ContentItemInterface(IOptions <GraphQLContentOptions> optionsAccessor)
        {
            _options = optionsAccessor.Value;

            Name = "ContentItem";

            Field(ci => ci.ContentItemId);
            Field(ci => ci.ContentItemVersionId);
            Field(ci => ci.ContentType);
            Field(ci => ci.DisplayText, nullable: true);
            Field(ci => ci.Published);
            Field(ci => ci.Latest);
            Field <DateTimeGraphType>("modifiedUtc", resolve: ci => ci.Source.ModifiedUtc);
            Field <DateTimeGraphType>("publishedUtc", resolve: ci => ci.Source.PublishedUtc);
            Field <DateTimeGraphType>("createdUtc", resolve: ci => ci.Source.CreatedUtc);
            Field(ci => ci.Owner);
            Field(ci => ci.Author);
        }
Beispiel #5
0
        public ContentItemType(IOptions <GraphQLContentOptions> optionsAccessor)
        {
            _options = optionsAccessor.Value;

            Name = "ContentItemType";

            Field(ci => ci.ContentItemId).Description("Content item id");
            Field(ci => ci.ContentItemVersionId).Description("The content item version id");
            Field(ci => ci.ContentType).Description("Type of content");
            Field(ci => ci.DisplayText).Description("The display text of the content item");
            Field(ci => ci.Published).Description("Is the published version");
            Field(ci => ci.Latest).Description("Is the latest version");
            Field <DateTimeGraphType>("modifiedUtc", resolve: ci => ci.Source.ModifiedUtc, description: "The date and time of modification");
            Field <DateTimeGraphType>("publishedUtc", resolve: ci => ci.Source.PublishedUtc, description: "The date and time of publication");
            Field <DateTimeGraphType>("createdUtc", resolve: ci => ci.Source.CreatedUtc, description: "The date and time of creation");
            Field(ci => ci.Owner).Description("The owner of the content item");
            Field(ci => ci.Author).Description("The author of the content item");

            Interface <ContentItemInterface>();

            IsTypeOf = IsContentType;
        }
Beispiel #6
0
 public GraphQLContentTypePartSettingsDriver(IOptions <GraphQLContentOptions> optionsAccessor)
 {
     _contentOptions = optionsAccessor.Value;
 }
 public TypedContentTypeBuilder(IHttpContextAccessor httpContextAccessor,
                                IOptions <GraphQLContentOptions> contentOptionsAccessor)
 {
     _httpContextAccessor = httpContextAccessor;
     _contentOptions      = contentOptionsAccessor.Value;
 }