Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration test for non-nullable files #4755

Merged
merged 1 commit into from Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions apollo-router/tests/fixtures/file_upload/schema.graphql
Expand Up @@ -82,6 +82,7 @@ type Mutation
@join__type(graph: UPLOADS_CLONE)
{
singleUpload(file: Upload): File @join__field(graph: UPLOADS)
singleUploadNonNull(file: Upload!): File! @join__field(graph: UPLOADS)
singleUploadClone(file: UploadClone): FileClone @join__field(graph: UPLOADS_CLONE)
multiUpload(files: [Upload!]!): [File!]! @join__field(graph: UPLOADS)
nestedUpload(nested: NestedUpload): File @join__field(graph: UPLOADS)
Expand Down
53 changes: 53 additions & 0 deletions apollo-router/tests/integration/file_upload.rs
Expand Up @@ -373,6 +373,59 @@ async fn it_supports_compression() -> Result<(), BoxError> {
.await
}

#[tokio::test(flavor = "multi_thread")]
async fn it_supports_non_nullable_file() -> Result<(), BoxError> {
use reqwest::multipart::Form;
use reqwest::multipart::Part;

// Construct a manual request for non nullable checks
let request = Form::new()
.part(
"operations",
Part::text(
serde_json::json!({
"query": "mutation SomeMutation($file0: Upload!) {
file0: singleUploadNonNull(file: $file0) { filename body }
}",
"variables": {
"file0": null,
},
})
.to_string(),
),
)
.part(
"map",
Part::text(
serde_json::json!({
"0": ["variables.file0"],
})
.to_string(),
),
)
.part("0", Part::text("file0 contents").file_name("file0"));

helper::FileUploadTestServer::builder()
.config(FILE_CONFIG)
.handler(make_handler!(helper::echo_single_file))
.request(request)
.subgraph_mapping("uploads", "/")
.build()
.run_test(|request| {
insta::assert_json_snapshot!(request, @r###"
{
"data": {
"file0": {
"filename": "file0",
"body": "file0 contents"
}
}
}
"###);
})
.await
}

#[tokio::test(flavor = "multi_thread")]
async fn it_supports_nested_file() -> Result<(), BoxError> {
use reqwest::multipart::Form;
Expand Down