Skip to content

Commit

Permalink
Fixed upload scalar on SS (#5330)
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalSenn authored Aug 22, 2022
1 parent 452bd1d commit 36c737b
Show file tree
Hide file tree
Showing 12 changed files with 1,169 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ private static void GetFileValueOrDefault(
{
value = (source, key) switch
{
(Dictionary<string, object?> s, string prop) => s[prop],
(List<object> l, int i) => l[i],
_ => null,
(Dictionary<string, object?> s, string prop) when s.ContainsKey(prop) => s[prop],
(List<object> l, int i) when i < l.Count => l[i],
_ => null
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ private static void AddFileMapMethods(
Name: { Value: "Upload" }
})
{
return;
continue;
}

classBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void Map(ClientModel model, IMapperContext context)
INamedTypeDescriptor namedTypeDescriptor =
context.Types.Single(type => type.Name.Equals(typeName));

hasUpload = namedTypeDescriptor.HasUpload();
hasUpload = hasUpload || namedTypeDescriptor.HasUpload();

return new PropertyDescriptor(
arg.Name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,39 @@ scalar Upload
",
"extend schema @key(fields: \"id\")");
}

[Fact]
public void Operation_With_FirstNonUpload()
{
AssertResult(
@"query test(
$string: String!
$upload: Upload!) {
foo(string: $string upload: $upload)
}",
@"type Query {
foo(string: String! upload: Upload!): String
}
scalar Upload
",
"extend schema @key(fields: \"id\")");
}

[Fact]
public void Operation_With_LastNonUpload()
{
AssertResult(
@"query test(
$upload: Upload!
$string: String!) {
foo(string: $string upload: $upload)
}",
@"type Query {
foo(string: String! upload: Upload!): String
}
scalar Upload
",
"extend schema @key(fields: \"id\")");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,15 @@ public void StarWarsIntrospection() =>

private const string UploadQueries = @"
query TestUpload(
$nonUpload: String
$single: Upload
$list: [Upload]
$nested: [[Upload]]
$object: TestInput
$objectList: [TestInput]
$objectNested: [[TestInput]]) {
upload(
upload(
nonUpload: $nonUpload
single: $single
list: $list
nested: $nested
Expand All @@ -208,6 +210,7 @@ query TestUpload(
private const string UploadSchema = @"
type Query {
upload(
nonUpload: String
single: Upload
list: [Upload]
nested: [[Upload]]
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public async Task Execute_UploadScalar_Argument()

// act
var result = await client.TestUpload.ExecuteAsync(
"nonUpload",
new Upload(data, "test-file"),
null,
null,
Expand All @@ -52,6 +53,7 @@ public async Task Execute_UploadScalarList_Argument()

// act
var result = await client.TestUpload.ExecuteAsync(
"nonUpload",
null,
new Upload?[] { new Upload(dataA, "A"), new Upload(dataB, "B") },
null,
Expand All @@ -76,6 +78,7 @@ public async Task Execute_UploadScalarNested_Argument()

// act
var result = await client.TestUpload.ExecuteAsync(
"nonUpload",
null,
null,
new[] { new Upload?[] { new Upload(dataA, "A"), new Upload(dataB, "B") } },
Expand All @@ -99,6 +102,7 @@ public async Task Execute_Input_Argument()

// act
var result = await client.TestUpload.ExecuteAsync(
"nonUpload",
null,
null,
null,
Expand Down Expand Up @@ -128,6 +132,7 @@ public async Task Execute_InputList_Argument()
using var dataB = CreateStream("b");
// act
var result = await client.TestUpload.ExecuteAsync(
"nonUpload",
null,
null,
null,
Expand Down Expand Up @@ -168,6 +173,7 @@ public async Task Execute_InputNested_Argument()

// act
var result = await client.TestUpload.ExecuteAsync(
"nonUpload",
null,
null,
null,
Expand Down Expand Up @@ -225,6 +231,7 @@ public async Task Execute_ListWorksWithNull()

// act
var result = await client.TestUpload.ExecuteAsync(
"nonUpload",
null,
new Upload?[] { new Upload(dataA, "A"), null, new Upload(dataB, "B") },
null,
Expand Down
Loading

0 comments on commit 36c737b

Please sign in to comment.