Skip to content

Commit 1246b69

Browse files
authored
dataconnect: test: Add integration tests for operations with empty selection sets (#7435)
1 parent 3190085 commit 1246b69

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.firebase.dataconnect.connectors.demo
17+
18+
import com.google.firebase.dataconnect.connectors.demo.testutil.DemoConnectorIntegrationTestBase
19+
import com.google.firebase.dataconnect.testutil.property.arbitrary.dataConnect
20+
import io.kotest.assertions.withClue
21+
import io.kotest.matchers.nulls.shouldNotBeNull
22+
import io.kotest.matchers.shouldBe
23+
import io.kotest.property.Arb
24+
import io.kotest.property.arbitrary.next
25+
import kotlinx.coroutines.test.runTest
26+
import org.junit.Test
27+
28+
class EmptySelectionSetIntegrationTest : DemoConnectorIntegrationTestBase() {
29+
30+
@Test
31+
fun queryWithEmptySelectionSet() = runTest {
32+
val id = Arb.dataConnect.id().next(rs)
33+
val queryResult = connector.getFooByIdEmptySelectionSet.execute(id)
34+
queryResult.data shouldBe Unit
35+
}
36+
37+
@Test
38+
fun mutationWithEmptySelectionSet() = runTest {
39+
val id = Arb.dataConnect.id().next(rs)
40+
val barValue = "bar" + Arb.dataConnect.id().next(rs)
41+
42+
val mutationResult = connector.upsertFooEmptySelectionSet.execute(id) { bar = barValue }
43+
44+
withClue("mutationResult.data") { mutationResult.data shouldBe Unit }
45+
val foo = withClue("getFooById") { connector.getFooById.execute(id).data.foo.shouldNotBeNull() }
46+
withClue("foo.bar") { foo.bar shouldBe barValue }
47+
}
48+
}

firebase-dataconnect/emulator/dataconnect/connector/demo/demo_ops.gql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ query GetHardcodedFoo
7070
}
7171
}
7272

73+
# This is an example mutation that has an empty selection set (Googlers see b/448629126).
74+
mutation UpsertFooEmptySelectionSet($id: String!, $bar: String) @auth(level: PUBLIC) {
75+
foo_upsert(data: {id: $id, bar: $bar}) @redact
76+
}
77+
78+
# This is an example query that has an empty selection set (Googlers see b/448629126).
79+
query GetFooByIdEmptySelectionSet($id: String!) @auth(level: PUBLIC) {
80+
foo(id: $id) @redact { bar }
81+
}
82+
7383
mutation InsertStringVariants(
7484
$nonNullWithNonEmptyValue: String!,
7585
$nonNullWithEmptyValue: String!,

0 commit comments

Comments
 (0)