Browse Source

Closes #172

pull/177/head
Sebastian Stehle 8 years ago
parent
commit
47df01e911
  1. 2
      src/Squidex.Domain.Apps.Core.Model/Schemas/Schema.cs
  2. 4
      src/Squidex.Domain.Apps.Read/Contents/GraphQL/GraphQLModel.cs
  3. 27
      tests/Squidex.Domain.Apps.Read.Tests/Contents/GraphQLTests.cs

2
src/Squidex.Domain.Apps.Core.Model/Schemas/Schema.cs

@ -109,7 +109,7 @@ namespace Squidex.Domain.Apps.Core.Schemas
if (fieldsByName.ContainsKey(field.Name) || fieldsById.ContainsKey(field.Id))
{
throw new ArgumentException($"A field with name '{field.Name}' already exists.", nameof(field));
throw new ArgumentException($"A field with name '{field.Name}' and id {field.Id} already exists.", nameof(field));
}
fieldsById.Add(field.Id, field);

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

@ -71,6 +71,10 @@ namespace Squidex.Domain.Apps.Read.Contents.GraphQL
typeof(JsonField),
field => ResolveDefault("Json")
},
{
typeof(TagsField),
field => ResolveDefault("String")
},
{
typeof(GeolocationField),
field => ResolveDefault("Geolocation")

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

@ -76,6 +76,9 @@ namespace Squidex.Domain.Apps.Read.Contents
schemaDef.AddField(new GeolocationField(10, "my-geolocation", Partitioning.Invariant,
new GeolocationFieldProperties()));
schemaDef.AddField(new TagsField(11, "my-tags", Partitioning.Invariant,
new TagsFieldProperties()));
A.CallTo(() => app.Id).Returns(appId);
A.CallTo(() => app.PartitionResolver).Returns(x => InvariantPartitioning.Instance);
@ -270,6 +273,9 @@ namespace Squidex.Domain.Apps.Read.Contents
myGeolocation {
iv
}
myTags {
iv
}
}
}
}";
@ -330,6 +336,14 @@ namespace Squidex.Domain.Apps.Read.Contents
latitude = 10,
longitude = 20
}
},
myTags = new
{
iv = new[]
{
"tag1",
"tag2"
}
}
}
}
@ -375,6 +389,9 @@ namespace Squidex.Domain.Apps.Read.Contents
myGeolocation {{
iv
}}
myTags {{
iv
}}
}}
}}
}}";
@ -429,6 +446,14 @@ namespace Squidex.Domain.Apps.Read.Contents
latitude = 10,
longitude = 20
}
},
myTags = new
{
iv = new[]
{
"tag1",
"tag2"
}
}
}
}
@ -629,6 +654,8 @@ namespace Squidex.Domain.Apps.Read.Contents
new ContentFieldData().AddValue("iv", true))
.AddField("my-datetime",
new ContentFieldData().AddValue("iv", now.ToDateTimeUtc()))
.AddField("my-tags",
new ContentFieldData().AddValue("iv", JToken.FromObject(new[] { "tag1", "tag2" })))
.AddField("my-references",
new ContentFieldData().AddValue("iv", JToken.FromObject(new[] { refId })))
.AddField("my-geolocation",

Loading…
Cancel
Save