Skip to content

Commit

Permalink
Fix casing for arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
byme8 committed Sep 25, 2023
1 parent b5f471f commit d1b5e5c
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/TestApp/TestStandardLibrary/Generated/GraphQL.g.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// d2b780c89b6d8a786ffdeaaa61bafb2a
// f65749114a308e455ddf7887448a84bf
// This file generated for ZeroQL.
// <auto-generated/>
#pragma warning disable 8618
Expand Down Expand Up @@ -294,7 +294,7 @@ public class Mutation : global::ZeroQL.Internal.IMutation
public int __AddUserProfileImage { get; set; }

[ZeroQL.GraphQLName("addUserProfileImage")]
public int AddUserProfileImage([ZeroQL.GraphQLType("Int!")] int userId = default !, [ZeroQL.GraphQLType("Upload!")] global::ZeroQL.Upload file = default !)
public int AddUserProfileImage([ZeroQL.GraphQLType("Int!")] int USER_ID = default !, [ZeroQL.GraphQLType("Upload!")] global::ZeroQL.Upload file = default !)
{
return __AddUserProfileImage;
}
Expand Down
4 changes: 2 additions & 2 deletions src/TestApp/ZeroQL.TestApp/Generated/GraphQL.g.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 13f414ba7b9b7b647d5105e3b9697837
// 20d623e33d26750331c67284f59b7f46
// This file generated for ZeroQL.
// <auto-generated/>
#pragma warning disable 8618
Expand Down Expand Up @@ -294,7 +294,7 @@ public class Mutation : global::ZeroQL.Internal.IMutation
public int __AddUserProfileImage { get; set; }

[ZeroQL.GraphQLName("addUserProfileImage")]
public int AddUserProfileImage([ZeroQL.GraphQLType("Int!")] int userId = default !, [ZeroQL.GraphQLType("Upload!")] global::ZeroQL.Upload file = default !)
public int AddUserProfileImage([ZeroQL.GraphQLType("Int!")] int USER_ID = default !, [ZeroQL.GraphQLType("Upload!")] global::ZeroQL.Upload file = default !)
{
return __AddUserProfileImage;
}
Expand Down
2 changes: 1 addition & 1 deletion src/TestApp/ZeroQL.TestApp/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type Mutation {
timeOnly(timeOnly: TimeSpan!): TimeSpan!
addUser(firstName: String! lastName: String!): User!
doError: Int!
addUserProfileImage(userId: Int! file: Upload!): Int!
addUserProfileImage(USER_ID: Int! file: Upload!): Int!
addMyProfileImage(file: Upload!): Int!
addUsersInfo(users: [UserInfoInput!]!): Int!
addUsersInfoWithEmails(input: AddUsersInput!): Int!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ private static Result<string> HandleFieldSelector(
var parametersToIgnore = ignoreLastParameter ? 1 : 0;
var argumentNames = method.Parameters
.Take(method.Parameters.Length - parametersToIgnore)
.Select(o => o.Name.FirstToLower())
.Select(o => o.Name)
.ToArray();

var (selectorName, error) = ExtractSelectorName(context, invocation.Expression).Unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/ZeroQL.TestServer/Query/UserGraphQLMutations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public int DoError(IResolverContext context)
}));
}

public async Task<int> AddUserProfileImage(int userId, IFile file)
public async Task<int> AddUserProfileImage([GraphQLName("USER_ID")]int userId, IFile file)
{
var stream = file.OpenReadStream();
var streamReader = new StreamReader(stream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ namespace GraphQLClient
public int __AddUserProfileImage { get; set; }

[ZeroQL.GraphQLName("addUserProfileImage")]
public int AddUserProfileImage([ZeroQL.GraphQLType("Int!")] int userId = default !, [ZeroQL.GraphQLType("Upload!")] global::ZeroQL.Upload file = default !)
public int AddUserProfileImage([ZeroQL.GraphQLType("Int!")] int USER_ID = default !, [ZeroQL.GraphQLType("Upload!")] global::ZeroQL.Upload file = default !)
{
return __AddUserProfileImage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
DateOnly DateOnly([ZeroQL.GraphQLType("Date!")] DateOnly dateOnly = default !),
TimeSpan TimeOnly([ZeroQL.GraphQLType("TimeSpan!")] TimeSpan timeOnly = default !),
T AddUser<T>([ZeroQL.GraphQLType("String!")] string firstName = default !, [ZeroQL.GraphQLType("String!")] string lastName = default !, Func<User, T> selector = default !),
int AddUserProfileImage([ZeroQL.GraphQLType("Int!")] int userId = default !, [ZeroQL.GraphQLType("Upload!")] global::ZeroQL.Upload file = default !),
int AddUserProfileImage([ZeroQL.GraphQLType("Int!")] int USER_ID = default !, [ZeroQL.GraphQLType("Upload!")] global::ZeroQL.Upload file = default !),
int AddMyProfileImage([ZeroQL.GraphQLType("Upload!")] global::ZeroQL.Upload file = default !),
int AddUsersInfo([ZeroQL.GraphQLType("[UserInfoInput!]!")] UserInfoInput[] users = default !),
int AddUsersInfoWithEmails([ZeroQL.GraphQLType("AddUsersInput!")] AddUsersInput input = default !),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ namespace GraphQLClient
public int __AddUserProfileImage { get; set; }

[ZeroQL.GraphQLName("addUserProfileImage")]
public int AddUserProfileImage([ZeroQL.GraphQLType("Int!")] int userId = default !, [ZeroQL.GraphQLType("Upload!")] global::ZeroQL.Upload file = default !)
public int AddUserProfileImage([ZeroQL.GraphQLType("Int!")] int USER_ID = default !, [ZeroQL.GraphQLType("Upload!")] global::ZeroQL.Upload file = default !)
{
return __AddUserProfileImage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Mutation {
timeOnly(timeOnly: TimeSpan!): TimeSpan!
addUser(firstName: String! lastName: String!): User!
doError: Int!
addUserProfileImage(userId: Int! file: Upload!): Int!
addUserProfileImage(USER_ID: Int! file: Upload!): Int!
addMyProfileImage(file: Upload!): Int!
addUsersInfo(users: [UserInfoInput!]!): Int!
addUsersInfoWithEmails(input: AddUsersInput!): Int!
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
Query: mutation ($userId: Int!, $file: Upload!) { addUserProfileImage(USER_ID: $userId, file: $file)},
Data: 42
}
7 changes: 3 additions & 4 deletions src/ZeroQL.Tests/SourceGeneration/FileUploadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ public async Task UploadFileAsClassInstance()
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.FullMeQuery, csharpQuery));

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

await Verify(result);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
Query: mutation AddAvatar($userId: Int!, $file: Upload!) { addUserProfileImage(USER_ID: $userId, file: $file)},
Data: 42
}
6 changes: 2 additions & 4 deletions src/ZeroQL.Tests/SourceGeneration/RequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,13 @@ public async Task CanSendRequestLikeMutation()
public async Task CanSendRequestLikeMutationWithUpload()
{
var csharpQuery = "await qlClient.Execute(new AddAvatar(1, new Upload(\"image.png\", new MemoryStream(new byte[42]))));";
var graphqlQuery = "mutation AddAvatar($userId: Int!, $file: Upload!) { addUserProfileImage(userId: $userId, file: $file)}";

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

dynamic response = await project.Validate(graphqlQuery);
int id = response.Data;
var response = await project.Execute();

id.Should().Be(42);
await Verify(response);
}

[Fact]
Expand Down

0 comments on commit d1b5e5c

Please sign in to comment.