Browse Source

Fix null checks.

pull/967/head
Sebastian 3 years ago
parent
commit
3fa17837ae
  1. 40
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ApplicationMutations.cs
  2. 25
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLMutationTests.cs

40
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ApplicationMutations.cs

@ -7,6 +7,7 @@
using GraphQL.Types;
using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Contents;
using Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Primitives;
namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types;
@ -26,8 +27,7 @@ internal sealed class ApplicationMutations : ObjectGraphType
var contentType = builder.GetContentType(schemaInfo);
// We cannot check before if all fields can be resolved. This might not be the case, e.g. if a reference is empty.
if (contentType == null || contentType.Fields.Count == 0)
if (contentType == null)
{
continue;
}
@ -38,7 +38,7 @@ internal sealed class ApplicationMutations : ObjectGraphType
{
Name = $"create{schemaInfo.TypeName}Content",
Arguments = ContentActions.Create.Arguments(inputType),
ResolvedType = nonNullContentType,
ResolvedType = contentType,
Resolver = ContentActions.Create.Resolver,
Description = $"Creates an {schemaInfo.DisplayName} content."
}).WithSchemaNamedId(schemaInfo);
@ -47,7 +47,7 @@ internal sealed class ApplicationMutations : ObjectGraphType
{
Name = $"update{schemaInfo.TypeName}Content",
Arguments = ContentActions.Update.Arguments(inputType),
ResolvedType = nonNullContentType,
ResolvedType = contentType,
Resolver = ContentActions.Update.Resolver,
Description = $"Update an {schemaInfo.DisplayName} content by id."
}).WithSchemaNamedId(schemaInfo);
@ -56,7 +56,7 @@ internal sealed class ApplicationMutations : ObjectGraphType
{
Name = $"upsert{schemaInfo.TypeName}Content",
Arguments = ContentActions.Upsert.Arguments(inputType),
ResolvedType = nonNullContentType,
ResolvedType = contentType,
Resolver = ContentActions.Upsert.Resolver,
Description = $"Upsert an {schemaInfo.DisplayName} content by id."
}).WithSchemaNamedId(schemaInfo);
@ -65,10 +65,38 @@ internal sealed class ApplicationMutations : ObjectGraphType
{
Name = $"patch{schemaInfo.TypeName}Content",
Arguments = ContentActions.Patch.Arguments(inputType),
ResolvedType = nonNullContentType,
ResolvedType = contentType,
Resolver = ContentActions.Patch.Resolver,
Description = $"Patch an {schemaInfo.DisplayName} content by id."
}).WithSchemaNamedId(schemaInfo);
AddField(new FieldType
{
Name = $"change{schemaInfo.TypeName}Content",
Arguments = ContentActions.ChangeStatus.Arguments,
ResolvedType = contentType,
Resolver = ContentActions.ChangeStatus.Resolver,
Description = $"Change a {schemaInfo.DisplayName} content."
}).WithSchemaNamedId(schemaInfo);
AddField(new FieldType
{
Name = $"delete{schemaInfo.TypeName}Content",
Arguments = ContentActions.Delete.Arguments,
ResolvedType = EntitySavedGraphType.NonNull,
Resolver = ContentActions.Delete.Resolver,
Description = $"Delete an {schemaInfo.DisplayName} content."
}).WithSchemaNamedId(schemaInfo);
AddField(new FieldType
{
Name = $"publish{schemaInfo.TypeName}Content",
Arguments = ContentActions.ChangeStatus.Arguments,
ResolvedType = contentType,
Resolver = ContentActions.ChangeStatus.Resolver,
Description = $"Publish a {schemaInfo.DisplayName} content.",
DeprecationReason = $"Use 'change{schemaInfo.TypeName}Content' instead"
}).WithSchemaNamedId(schemaInfo);
}
Description = "The app mutations.";

25
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/GraphQL/GraphQLMutationTests.cs

@ -64,7 +64,10 @@ public class GraphQLMutationTests : GraphQLTestBase
}
}
},
data = (object?)null
data = new
{
createMySchemaContent = (object?)null
}
};
AssertResult(expected, actual);
@ -215,7 +218,10 @@ public class GraphQLMutationTests : GraphQLTestBase
}
}
},
data = (object?)null
data = new
{
updateMySchemaContent = (object?)null
}
};
AssertResult(expected, actual);
@ -329,7 +335,10 @@ public class GraphQLMutationTests : GraphQLTestBase
}
}
},
data = (object?)null
data = new
{
upsertMySchemaContent = (object?)null
}
};
AssertResult(expected, actual);
@ -445,7 +454,10 @@ public class GraphQLMutationTests : GraphQLTestBase
}
}
},
data = (object?)null
data = new
{
patchMySchemaContent = (object?)null
}
};
AssertResult(expected, actual);
@ -559,7 +571,10 @@ public class GraphQLMutationTests : GraphQLTestBase
}
}
},
data = (object?)null
data = new
{
changeMySchemaContent = (object?)null
}
};
AssertResult(expected, actual);

Loading…
Cancel
Save