Browse Source

Bugfixes for invalid schema refs and cleanup of old classes.

pull/65/head
Sebastian Stehle 9 years ago
parent
commit
cbc609c962
  1. 7
      src/Squidex.Domain.Apps.Read/Contents/GraphQL/GraphQLModel.cs
  2. 37
      src/Squidex.Domain.Apps.Read/Contents/GraphQL/Types/GeolocationScalarType.cs
  3. 37
      src/Squidex.Domain.Apps.Read/Contents/GraphQL/Types/JsonScalarType.cs
  4. 4
      tests/Squidex.Domain.Apps.Read.Tests/Contents/GraphQLTests.cs

7
src/Squidex.Domain.Apps.Read/Contents/GraphQL/GraphQLModel.cs

@ -172,12 +172,9 @@ namespace Squidex.Domain.Apps.Read.Contents.GraphQL
public IGraphType GetSchemaType(Guid schemaId)
{
return schemaTypes.GetOrAdd(schemaId, k =>
{
var schemaEntity = schemas.GetOrDefault(k);
var schemaEntity = schemas.GetOrDefault(schemaId);
return schemaEntity != null ? new ContentGraphType(schemaEntity.Schema, this) : null;
});
return schemaEntity != null ? schemaTypes.GetOrAdd(schemaId, k => new ContentGraphType(schemaEntity.Schema, this)) : null;
}
}
}

37
src/Squidex.Domain.Apps.Read/Contents/GraphQL/Types/GeolocationScalarType.cs

@ -1,37 +0,0 @@
// ==========================================================================
// GeolocationScalarType.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
// All rights reserved.
// ==========================================================================
using GraphQL.Language.AST;
using GraphQL.Types;
using Newtonsoft.Json.Linq;
namespace Squidex.Domain.Apps.Read.Contents.GraphQL.Types
{
public sealed class GeolocationScalarType : ScalarGraphType
{
public GeolocationScalarType()
{
Name = "Json";
}
public override object Serialize(object value)
{
return value;
}
public override object ParseValue(object value)
{
return value != null ? value is JObject ? value : JObject.FromObject(value) : null;
}
public override object ParseLiteral(IValue value)
{
return null;
}
}
}

37
src/Squidex.Domain.Apps.Read/Contents/GraphQL/Types/JsonScalarType.cs

@ -1,37 +0,0 @@
// ==========================================================================
// JsonScalarType.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
// All rights reserved.
// ==========================================================================
using GraphQL.Language.AST;
using GraphQL.Types;
using Newtonsoft.Json.Linq;
namespace Squidex.Domain.Apps.Read.Contents.GraphQL.Types
{
public sealed class JsonScalarType : ScalarGraphType
{
public JsonScalarType()
{
Name = "Json";
}
public override object Serialize(object value)
{
return value;
}
public override object ParseValue(object value)
{
return value != null ? value is JObject ? value : JObject.FromObject(value) : null;
}
public override object ParseLiteral(IValue value)
{
return null;
}
}
}

4
tests/Squidex.Domain.Apps.Read.Tests/Contents/GraphQLTests.cs

@ -52,7 +52,9 @@ namespace Squidex.Domain.Apps.Read.Contents
new DateTimeFieldProperties()))
.AddOrUpdateField(new ReferencesField(7, "my-references", Partitioning.Invariant,
new ReferencesFieldProperties { SchemaId = schemaId }))
.AddOrUpdateField(new GeolocationField(8, "my-geolocation", Partitioning.Invariant,
.AddOrUpdateField(new ReferencesField(9, "my-invalid", Partitioning.Invariant,
new ReferencesFieldProperties { SchemaId = Guid.NewGuid() }))
.AddOrUpdateField(new GeolocationField(9, "my-geolocation", Partitioning.Invariant,
new GeolocationFieldProperties()));
private readonly Mock<ISchemaRepository> schemaRepository = new Mock<ISchemaRepository>();

Loading…
Cancel
Save