Browse Source

Cleanup.

pull/733/head
Sebastian 5 years ago
parent
commit
800940e76f
  1. 7
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ComponentGraphType.cs
  2. 27
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentGraphType.cs

7
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ComponentGraphType.cs

@ -21,14 +21,13 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
Description = $"The structure of the {schemaInfo.DisplayName} component schema."; Description = $"The structure of the {schemaInfo.DisplayName} component schema.";
AddField(ContentFields.SchemaId);
AddResolvedInterface(builder.SharedTypes.ComponentInterface);
IsTypeOf = CheckType(schemaInfo.Schema.Id.ToString()); IsTypeOf = CheckType(schemaInfo.Schema.Id.ToString());
} }
public void Initialize(Builder builder, SchemaInfo schemaInfo) public void Initialize(Builder builder, SchemaInfo schemaInfo)
{ {
AddField(ContentFields.SchemaId);
foreach (var fieldInfo in schemaInfo.Fields) foreach (var fieldInfo in schemaInfo.Fields)
{ {
if (fieldInfo.Field.IsComponentLike()) if (fieldInfo.Field.IsComponentLike())
@ -57,6 +56,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
}).WithSourceName(fieldInfo); }).WithSourceName(fieldInfo);
} }
} }
AddResolvedInterface(builder.SharedTypes.ComponentInterface);
} }
private static Func<object, bool> CheckType(string schemaId) private static Func<object, bool> CheckType(string schemaId)

27
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/ContentGraphType.cs

@ -21,6 +21,17 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
{ {
schemaId = schemaInfo.Schema.Id; schemaId = schemaInfo.Schema.Id;
IsTypeOf = CheckType;
}
private bool CheckType(object value)
{
return value is IContentEntity content && content.SchemaId?.Id == schemaId;
}
public void Initialize(Builder builder, SchemaInfo schemaInfo, IEnumerable<SchemaInfo> allSchemas)
{
Name = schemaInfo.ContentType; Name = schemaInfo.ContentType;
AddField(ContentFields.Id); AddField(ContentFields.Id);
@ -33,20 +44,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
AddField(ContentFields.LastModifiedByUser); AddField(ContentFields.LastModifiedByUser);
AddField(ContentFields.Status); AddField(ContentFields.Status);
AddField(ContentFields.StatusColor); AddField(ContentFields.StatusColor);
AddResolvedInterface(builder.SharedTypes.ContentInterface);
Description = $"The structure of a {schemaInfo.DisplayName} content type.";
IsTypeOf = CheckType;
}
private bool CheckType(object value)
{
return value is IContentEntity content && content.SchemaId?.Id == schemaId;
}
public void Initialize(Builder builder, SchemaInfo schemaInfo, IEnumerable<SchemaInfo> allSchemas)
{
AddField(new FieldType AddField(new FieldType
{ {
Name = "url", Name = "url",
@ -85,6 +83,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
{ {
AddReferencingQueries(builder, other); AddReferencingQueries(builder, other);
} }
AddResolvedInterface(builder.SharedTypes.ContentInterface);
Description = $"The structure of a {schemaInfo.DisplayName} content type.";
} }
private void AddReferencingQueries(Builder builder, SchemaInfo referencingSchemaInfo) private void AddReferencingQueries(Builder builder, SchemaInfo referencingSchemaInfo)

Loading…
Cancel
Save