Skip to content

Commit

Permalink
Fix anonymous type name conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Silin committed Aug 26, 2022
1 parent 69b7087 commit c913b7f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ZeroQL.SourceGenerators/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ public static string ToSafeGlobalName(this ISymbol symbol)
.Replace("[", "ArrayOf")
.Replace("]", "")
.Replace(" ", "")
.Replace(",", "")
.Replace(":", "")
.Replace(".", "");
}
Expand Down
13 changes: 13 additions & 0 deletions src/ZeroQL.Tests/SourceGeneration/FileUploadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ public async Task UploadFileAsClassInstance()
var result = (GraphQLResult<int>)await project.Validate(graphqlQuery);
result.Data.Should().Be(42);
}

[Fact]
public async Task UploadFileAsAnonymousTypeWithMultipleProperties()
{
var csharpQuery = "Mutation(new { UserId = 1, File = new Upload(\"image.png\", new MemoryStream(new byte[42])) }, static (i, m) => m.AddUserProfileImage(i.UserId, i.File))";
var graphqlQuery = @"mutation ($userId: Int!, $file: Upload!) { addUserProfileImage(userId: $userId, file: $file)}";

var project = await TestProject.Project
.ReplacePartOfDocumentAsync("Program.cs", (TestProject.FULL_ME_QUERY, csharpQuery));

var result = (GraphQLResult<int>)await project.Validate(graphqlQuery);
result.Data.Should().Be(42);
}

[Fact]
public async Task UploadFileAsAnonymousType()
Expand Down

0 comments on commit c913b7f

Please sign in to comment.