Skip to content

Commit

Permalink
Add a @JsName annotation to Operation.name() (#4643)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoD authored Jan 19, 2023
1 parent d6a7cdc commit d04472a
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface Operation<D : Operation.Data> : Executable<D> {
/**
* The GraphQL operation name as in the `*.graphql` file.
*/
@JsName("operationName")
fun name(): String

/**
Expand Down
5 changes: 3 additions & 2 deletions tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ if (System.getProperty("idea.sync.active") == null) {
":native-benchmarks:compileCommonMainKotlinMetadata",
":pagination:compileCommonMainKotlinMetadata",
":sqlite:compileCommonMainKotlinMetadata",
":websockets:compileCommonMainKotlinMetadata"
":websockets:compileCommonMainKotlinMetadata",
":js:compileCommonMainKotlinMetadata",
))
}
}
34 changes: 34 additions & 0 deletions tests/js/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
plugins {
id("org.jetbrains.kotlin.multiplatform")
id("apollo.test")
id("com.apollographql.apollo3")
}

apolloTest {
mpp {
withJvm.set(false)
appleTargets.set(emptySet())
}
}

kotlin {
sourceSets {
findByName("commonMain")?.apply {
dependencies {
implementation(golatac.lib("apollo.runtime"))
}
}

findByName("commonTest")?.apply {
dependencies {
implementation(golatac.lib("apollo.testingsupport"))
}
}
}
}

apollo {
service("service") {
packageName.set("js.test")
}
}
3 changes: 3 additions & 0 deletions tests/js/src/commonMain/graphql/operations.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mutation CreateCustomer($name: String!, $id: Int!) {
createCustomer(input: {customer: {storeId: $id, name: $name}})
}
16 changes: 16 additions & 0 deletions tests/js/src/commonMain/graphql/schema.graphqls
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type Query {
a: String
}

type Mutation {
createCustomer(input: CreateCustomerInput!): Boolean
}

input CreateCustomerInput {
customer: CustomerInput!
}

input CustomerInput {
storeId: Int!
name: String!
}
9 changes: 9 additions & 0 deletions tests/js/src/jsTest/kotlin/JsTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import js.test.CreateCustomerMutation
import kotlin.test.Test

class JsTest {
@Test
fun nameAndIdParametersCompile() {
CreateCustomerMutation(name = "a", id = 42)
}
}

0 comments on commit d04472a

Please sign in to comment.