Skip to content

Commit

Permalink
Fixed upload scalar on SS (#5329)
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalSenn committed Aug 22, 2022
1 parent 82d3330 commit 0576961
Show file tree
Hide file tree
Showing 12 changed files with 1,038 additions and 39 deletions.
Expand Up @@ -152,9 +152,9 @@ await interceptor
{
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
Expand Up @@ -446,7 +446,7 @@ private MethodBuilder CreateRequestMethod(OperationDescriptor descriptor)
}
else if (argument.Type.NamedType() is not ScalarTypeDescriptor { Name: "Upload" })
{
return;
continue;
}

classBuilder
Expand Down
Expand Up @@ -25,7 +25,7 @@ public static void Map(ClientModel model, IMapperContext context)
var namedTypeDescriptor =
context.Types.Single(type => type.Name.EqualsOrdinal(typeName));
hasUpload = namedTypeDescriptor.HasUpload();
hasUpload = hasUpload || namedTypeDescriptor.HasUpload();
return new PropertyDescriptor(
arg.Name,
Expand Down
Expand Up @@ -229,4 +229,40 @@ 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\")");
}
}
Expand Up @@ -264,13 +264,15 @@ public class TestGeneration
*/
private const string UploadQueries = @"
query TestUpload(
$nonUpload: String
$single: Upload
$list: [Upload]
$nested: [[Upload]]
$object: TestInput
$objectList: [TestInput]
$objectNested: [[TestInput]]) {
upload(
nonUpload: $nonUpload
single: $single
list: $list
nested: $nested
Expand All @@ -281,6 +283,7 @@ public class TestGeneration
private const string UploadSchema = @"
type Query {
upload(
nonUpload: String
single: Upload
list: [Upload]
nested: [[Upload]]
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -23,6 +23,7 @@ public async Task Execute_UploadScalar_Argument()

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

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

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

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

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

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

0 comments on commit 0576961

Please sign in to comment.