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 a @JsName annotation to Operation.name() #4643

Merged
merged 1 commit into from
Jan 19, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}