Browse Source

Bugfixes by creating resolvers manually.

pull/65/head
Sebastian Stehle 9 years ago
parent
commit
2679dca2b4
  1. 14
      Squidex.sln
  2. 14
      src/Squidex.Domain.Apps.Read.MongoDb/Contents/Visitors/PropertyVisitor.cs
  3. 148
      src/Squidex.Domain.Apps.Read/Contents/GraphQL/Types/AssetGraphType.cs
  4. 66
      src/Squidex.Domain.Apps.Read/Contents/GraphQL/Types/ContentGraphType.cs
  5. 4
      src/Squidex.Domain.Apps.Read/Contents/GraphQL/Types/ContentQueryType.cs
  6. 2
      src/Squidex.Domain.Apps.Read/Squidex.Domain.Apps.Read.csproj
  7. 1
      src/Squidex/Squidex.csproj

14
Squidex.sln

@ -56,6 +56,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.Domain.Users.MongoD
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.Domain.Users.Tests", "tests\Squidex.Domain.Users.Tests\Squidex.Domain.Users.Tests.csproj", "{42184546-E3CB-4D4F-9495-43979B9C63B9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL", "C:\Users\mail2\Downloads\graphql-dotnet\src\GraphQL\GraphQL.csproj", "{A1290A2F-E935-4666-95F0-E015293F5AF6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -266,6 +268,18 @@ Global
{42184546-E3CB-4D4F-9495-43979B9C63B9}.Release|x64.Build.0 = Release|Any CPU
{42184546-E3CB-4D4F-9495-43979B9C63B9}.Release|x86.ActiveCfg = Release|Any CPU
{42184546-E3CB-4D4F-9495-43979B9C63B9}.Release|x86.Build.0 = Release|Any CPU
{A1290A2F-E935-4666-95F0-E015293F5AF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1290A2F-E935-4666-95F0-E015293F5AF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1290A2F-E935-4666-95F0-E015293F5AF6}.Debug|x64.ActiveCfg = Debug|Any CPU
{A1290A2F-E935-4666-95F0-E015293F5AF6}.Debug|x64.Build.0 = Debug|Any CPU
{A1290A2F-E935-4666-95F0-E015293F5AF6}.Debug|x86.ActiveCfg = Debug|Any CPU
{A1290A2F-E935-4666-95F0-E015293F5AF6}.Debug|x86.Build.0 = Debug|Any CPU
{A1290A2F-E935-4666-95F0-E015293F5AF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1290A2F-E935-4666-95F0-E015293F5AF6}.Release|Any CPU.Build.0 = Release|Any CPU
{A1290A2F-E935-4666-95F0-E015293F5AF6}.Release|x64.ActiveCfg = Release|Any CPU
{A1290A2F-E935-4666-95F0-E015293F5AF6}.Release|x64.Build.0 = Release|Any CPU
{A1290A2F-E935-4666-95F0-E015293F5AF6}.Release|x86.ActiveCfg = Release|Any CPU
{A1290A2F-E935-4666-95F0-E015293F5AF6}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

14
src/Squidex.Domain.Apps.Read.MongoDb/Contents/Visitors/PropertyVisitor.cs

@ -46,9 +46,21 @@ namespace Squidex.Domain.Apps.Read.MongoDb.Contents.Visitors
return nodeIn.Source.Accept(this);
}
public override ImmutableList<string> Visit(SingleComplexNode nodeIn)
{
if (nodeIn.Source is SingleComplexNode)
{
return nodeIn.Source.Accept(this).Add(nodeIn.Property.Name);
}
else
{
return ImmutableList.Create(nodeIn.Property.Name);
}
}
public override ImmutableList<string> Visit(SingleValuePropertyAccessNode nodeIn)
{
if (nodeIn.Source is SingleValuePropertyAccessNode)
if (nodeIn.Source is SingleComplexNode)
{
return nodeIn.Source.Accept(this).Add(nodeIn.Property.Name);
}

148
src/Squidex.Domain.Apps.Read/Contents/GraphQL/Types/AssetGraphType.cs

@ -6,6 +6,8 @@
// All rights reserved.
// ==========================================================================
using System;
using GraphQL.Resolvers;
using GraphQL.Types;
using Squidex.Domain.Apps.Read.Assets;
@ -17,46 +19,116 @@ namespace Squidex.Domain.Apps.Read.Contents.GraphQL.Types
{
Name = "AssetDto";
Field("id", x => x.Id.ToString())
.Description("The id of the asset.");
Field("version", x => x.Version)
.Description("The version of the asset.");
Field("created", x => x.Created.ToDateTimeUtc())
.Description("The date and time when the asset has been created.");
Field("createdBy", x => x.CreatedBy.ToString())
.Description("The user that has created the asset.");
Field("lastModified", x => x.LastModified.ToDateTimeUtc())
.Description("The date and time when the asset has been modified last.");
Field("lastModifiedBy", x => x.LastModifiedBy.ToString())
.Description("The user that has updated the asset last.");
Field("mimeType", x => x.MimeType)
.Description("The mime type.");
Field("fileName", x => x.FileName)
.Description("The file name.");
Field("fileSize", x => x.FileSize)
.Description("The size of the file in bytes.");
Field("fileVersion", x => x.FileVersion)
.Description("The version of the file.");
Field("isImage", x => x.IsImage)
.Description("Determines of the created file is an image.");
Field("pixelWidth", x => x.PixelWidth, true)
.Description("The width of the image in pixels if the asset is an image.");
Field("pixelHeight", x => x.PixelHeight, true)
.Description("The height of the image in pixels if the asset is an image.");
AddField(new FieldType
{
Name = "id",
Resolver = Resolver(x => x.Id.ToString()),
ResolvedType = new NonNullGraphType(new StringGraphType()),
Description = "The id of the asset."
});
AddField(new FieldType
{
Name = "version",
Resolver = Resolver(x => x.Version),
ResolvedType = new NonNullGraphType(new IntGraphType()),
Description = "The version of the asset."
});
AddField(new FieldType
{
Name = "created",
Resolver = Resolver(x => x.Created.ToDateTimeUtc()),
ResolvedType = new NonNullGraphType(new DateGraphType()),
Description = "The date and time when the asset has been created."
});
AddField(new FieldType
{
Name = "createdBy",
Resolver = Resolver(x => x.CreatedBy.ToString()),
ResolvedType = new NonNullGraphType(new StringGraphType()),
Description = "The user that has created the asset."
});
AddField(new FieldType
{
Name = "lastModified",
Resolver = Resolver(x => x.LastModified.ToDateTimeUtc()),
ResolvedType = new NonNullGraphType(new DateGraphType()),
Description = "The date and time when the asset has been modified last."
});
AddField(new FieldType
{
Name = "lastModifiedBy",
Resolver = Resolver(x => x.LastModifiedBy.ToString()),
ResolvedType = new NonNullGraphType(new StringGraphType()),
Description = "The user that has updated the asset last."
});
AddField(new FieldType
{
Name = "mimeType",
Resolver = Resolver(x => x.MimeType),
ResolvedType = new NonNullGraphType(new StringGraphType()),
Description = "The mime type."
});
AddField(new FieldType
{
Name = "fileName",
Resolver = Resolver(x => x.FileName),
ResolvedType = new NonNullGraphType(new StringGraphType()),
Description = "The file name."
});
AddField(new FieldType
{
Name = "fileSize",
Resolver = Resolver(x => x.FileSize),
ResolvedType = new NonNullGraphType(new IntGraphType()),
Description = "The size of the file in bytes."
});
AddField(new FieldType
{
Name = "fileVersion",
Resolver = Resolver(x => x.FileVersion),
ResolvedType = new NonNullGraphType(new IntGraphType()),
Description = "The version of the file."
});
AddField(new FieldType
{
Name = "isImage",
Resolver = Resolver(x => x.IsImage),
ResolvedType = new NonNullGraphType(new BooleanGraphType()),
Description = "Determines of the created file is an image."
});
AddField(new FieldType
{
Name = "pixelWidth",
Resolver = Resolver(x => x.PixelWidth),
ResolvedType = new IntGraphType(),
Description = "The width of the image in pixels if the asset is an image."
});
AddField(new FieldType
{
Name = "pixelHeight",
Resolver = Resolver(x => x.PixelHeight),
ResolvedType = new IntGraphType(),
Description = "The height of the image in pixels if the asset is an image."
});
Description = "An asset";
}
private static IFieldResolver Resolver(Func<IAssetEntity, object> action)
{
return new FuncFieldResolver<IAssetEntity, object>(c => action(c.Source));
}
}
}

66
src/Squidex.Domain.Apps.Read/Contents/GraphQL/Types/ContentGraphType.cs

@ -6,9 +6,9 @@
// All rights reserved.
// ==========================================================================
using System;
using GraphQL.Resolvers;
using GraphQL.Types;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Infrastructure;
using Schema = Squidex.Domain.Apps.Core.Schemas.Schema;
@ -16,42 +16,74 @@ namespace Squidex.Domain.Apps.Read.Contents.GraphQL.Types
{
public sealed class ContentGraphType : ObjectGraphType<IContentEntity>
{
private static readonly IFieldResolver DataResolver =
new FuncFieldResolver<IContentEntity, NamedContentData>(c => c.Source.Data);
public ContentGraphType(Schema schema, IGraphQLContext graphQLContext)
{
var schemaName = schema.Properties.Label.WithFallback(schema.Name);
Name = $"{schema.Name.ToPascalCase()}Dto";
Field("id", x => x.Id.ToString())
.Description($"The id of the {schemaName} content.");
AddField(new FieldType
{
Name = "id",
Resolver = Resolver(x => x.Id.ToString()),
ResolvedType = new NonNullGraphType(new StringGraphType()),
Description = $"The id of the {schemaName} content."
});
Field("version", x => x.Version)
.Description($"The version of the {schemaName} content.");
AddField(new FieldType
{
Name = "version",
Resolver = Resolver(x => x.Version),
ResolvedType = new NonNullGraphType(new IntGraphType()),
Description = $"The version of the {schemaName} content."
});
Field("created", x => x.Created.ToDateTimeUtc())
.Description($"The date and time when the {schemaName} content has been created.");
AddField(new FieldType
{
Name = "created",
Resolver = Resolver(x => x.Created.ToDateTimeUtc()),
ResolvedType = new NonNullGraphType(new DateGraphType()),
Description = $"The date and time when the {schemaName} content has been created."
});
Field("createdBy", x => x.CreatedBy.ToString())
.Description($"The user that has created the {schemaName} content.");
AddField(new FieldType
{
Name = "createdBy",
Resolver = Resolver(x => x.CreatedBy.ToString()),
ResolvedType = new NonNullGraphType(new StringGraphType()),
Description = $"The user that has created the {schemaName} content."
});
Field("lastModified", x => x.LastModified.ToDateTimeUtc())
.Description($"The date and time when the {schemaName} content has been modified last.");
AddField(new FieldType
{
Name = "lastModified",
Resolver = Resolver(x => x.LastModified.ToDateTimeUtc()),
ResolvedType = new NonNullGraphType(new DateGraphType()),
Description = $"The date and time when the {schemaName} content has been modified last."
});
Field("lastModifiedBy", x => x.LastModifiedBy.ToString())
.Description($"The user that has updated the {schemaName} content last.");
AddField(new FieldType
{
Name = "lastModifiedBy",
Resolver = Resolver(x => x.LastModifiedBy.ToString()),
ResolvedType = new NonNullGraphType(new StringGraphType()),
Description = $"The user that has updated the {schemaName} content last."
});
AddField(new FieldType
{
Name = "data",
Resolver = DataResolver,
Resolver = Resolver(x => x.Data),
ResolvedType = new NonNullGraphType(new ContentDataGraphType(schema, graphQLContext)),
Description = $"The data of the {schemaName} content."
});
Description = $"The structure of a {schemaName} content type.";
}
private static IFieldResolver Resolver(Func<IContentEntity, object> action)
{
return new FuncFieldResolver<IContentEntity, object>(c => action(c.Source));
}
}
}

4
src/Squidex.Domain.Apps.Read/Contents/GraphQL/Types/ContentQueryType.cs

@ -65,7 +65,7 @@ namespace Squidex.Domain.Apps.Read.Contents.GraphQL.Types
{
AddField(new FieldType
{
Name = $"find{schemaEntity.Name.ToPascalCase()}",
Name = $"find{schemaEntity.Name.ToPascalCase()}Content",
Arguments = new QueryArguments
{
new QueryArgument(typeof(StringGraphType))
@ -132,7 +132,7 @@ namespace Squidex.Domain.Apps.Read.Contents.GraphQL.Types
{
AddField(new FieldType
{
Name = $"query{schemaEntity.Name.ToPascalCase()}",
Name = $"query{schemaEntity.Name.ToPascalCase()}Contents",
Arguments = new QueryArguments
{
new QueryArgument(typeof(IntGraphType))

2
src/Squidex.Domain.Apps.Read/Squidex.Domain.Apps.Read.csproj

@ -11,9 +11,9 @@
<ProjectReference Include="..\Squidex.Domain.Apps.Core\Squidex.Domain.Apps.Core.csproj" />
<ProjectReference Include="..\Squidex.Domain.Apps.Events\Squidex.Domain.Apps.Events.csproj" />
<ProjectReference Include="..\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />
<ProjectReference Include="C:\Users\mail2\Downloads\graphql-dotnet\src\GraphQL\GraphQL.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="GraphQL" Version="0.16.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="1.1.2" />
<PackageReference Include="NodaTime" Version="2.0.3" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.7.0" />

1
src/Squidex/Squidex.csproj

@ -38,6 +38,7 @@
<ProjectReference Include="..\Squidex.Domain.Apps.Read.MongoDb\Squidex.Domain.Apps.Read.MongoDb.csproj" />
<ProjectReference Include="..\Squidex.Domain.Apps.Write\Squidex.Domain.Apps.Write.csproj" />
<ProjectReference Include="..\Squidex.Shared\Squidex.Shared.csproj" />
<ProjectReference Include="C:\Users\mail2\Downloads\graphql-dotnet\src\GraphQL\GraphQL.csproj" />
</ItemGroup>
<ItemGroup>

Loading…
Cancel
Save