Browse Source

Fix graphql for empty nested fields.

pull/680/head
Sebastian Stehle 5 years ago
parent
commit
6c02c38d6a
  1. 5
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldInputVisitor.cs
  2. 9
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldVisitor.cs
  3. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLTestBase.cs

5
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldInputVisitor.cs

@ -21,6 +21,11 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
public IGraphType? Visit(IArrayField field, FieldInfo args) public IGraphType? Visit(IArrayField field, FieldInfo args)
{ {
if (args.Fields.Count == 0)
{
return null;
}
var schemaFieldType = var schemaFieldType =
new ListGraphType( new ListGraphType(
new NonNullGraphType( new NonNullGraphType(

9
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Contents/FieldVisitor.cs

@ -97,6 +97,11 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
public (IGraphType?, IFieldResolver?, QueryArguments?) Visit(IArrayField field, FieldInfo args) public (IGraphType?, IFieldResolver?, QueryArguments?) Visit(IArrayField field, FieldInfo args)
{ {
if (args.Fields.Count == 0)
{
return default;
}
var schemaFieldType = var schemaFieldType =
new ListGraphType( new ListGraphType(
new NonNullGraphType( new NonNullGraphType(
@ -152,7 +157,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
public (IGraphType?, IFieldResolver?, QueryArguments?) Visit(IField<UIFieldProperties> field, FieldInfo args) public (IGraphType?, IFieldResolver?, QueryArguments?) Visit(IField<UIFieldProperties> field, FieldInfo args)
{ {
return (null, null, null); return default;
} }
private (IGraphType?, IFieldResolver?, QueryArguments?) ResolveReferences(IField<ReferencesFieldProperties> field, FieldInfo args) private (IGraphType?, IFieldResolver?, QueryArguments?) ResolveReferences(IField<ReferencesFieldProperties> field, FieldInfo args)
@ -165,7 +170,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents
if (!union.PossibleTypes.Any()) if (!union.PossibleTypes.Any())
{ {
return (null, null, null); return default;
} }
contentType = union; contentType = union;

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLTestBase.cs

@ -100,6 +100,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
new GeolocationFieldProperties()) new GeolocationFieldProperties())
.AddTags(14, "my-tags", Partitioning.Invariant, .AddTags(14, "my-tags", Partitioning.Invariant,
new TagsFieldProperties()) new TagsFieldProperties())
.AddArray(20, "my-empty-array", Partitioning.Invariant, null,
new ArrayFieldProperties())
.AddArray(15, "my-array", Partitioning.Invariant, f => f .AddArray(15, "my-array", Partitioning.Invariant, f => f
.AddBoolean(121, "nested-boolean") .AddBoolean(121, "nested-boolean")
.AddNumber(122, "nested-number") .AddNumber(122, "nested-number")

Loading…
Cancel
Save