Skip to content

[gradle plugin] GraphQL extension cannot be used from Groovy scripts #893

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

Closed
dariuszkuc opened this issue Oct 1, 2020 · 1 comment · Fixed by #901
Closed

[gradle plugin] GraphQL extension cannot be used from Groovy scripts #893

dariuszkuc opened this issue Oct 1, 2020 · 1 comment · Fixed by #901
Labels
type: bug Something isn't working

Comments

@dariuszkuc
Copy link
Collaborator

Library Version
4.0.0-alpha.4

Describe the bug
GraphQLPluginExtension is using Kotlin lambdas for configuration which makes it unusable from Groovy build files. We should use Gradle Action instead of lambdas - i.e. instead of GraphQLPluginClientExtension.() -> Unit use Action<GraphQLPluginClientExtension>

To Reproduce
Apply graphql extension in build.gradle

graphql {
    client {
        endpoint = "http://localhost:8080/graphql"
        packageName = "com.example"
        clientType = GraphQLClientType.KTOR
    }
}

Expected behavior
GraphQL extension DSL can be used from both Groovy and Kotlin scripts.

Workaround
Instead of extension we can configure tasks explicitly

tasks.getByName("graphqlIntrospectSchema") {
    endpoint.set("http://localhost:8080/graphql")
}
tasks.getByName("graphqlGenerateClient") {
    packageName.set("com.example")
    clientType.set(com.expediagroup.graphql.plugin.generator.GraphQLClientType.KTOR)
    schemaFile.set(graphqlIntrospectSchema.outputFile)
    dependsOn("graphqlIntrospectSchema")
}
@dariuszkuc dariuszkuc added type: bug Something isn't working Hacktoberfest labels Oct 1, 2020
@dariuszkuc
Copy link
Collaborator Author

When working on this issue we should also update our documentation with samples for both Kotlin and Groovy based build files.

dariuszkuc added a commit to dariuszkuc/graphql-kotlin that referenced this issue Oct 9, 2020
Originally extension was using Kotlin lambdas for some configuration which worked fine when used from Kotlin script (`build.gralde.kts`) but it could not be easily used from Groovy scripts (`build.gradle`). By changing from lambda with a receiver to a Groovy Action the resulting code will be translated using SAM conversion that makes it possible to configure the extension using Kotlin lambda or Groovy closure.

Resolves: ExpediaGroup#893
dariuszkuc added a commit to dariuszkuc/graphql-kotlin that referenced this issue Oct 9, 2020
Originally extension was using Kotlin lambdas for some configuration which worked fine when used from Kotlin script (`build.gralde.kts`) but it could not be easily used from Groovy scripts (`build.gradle`). By changing from lambda with a receiver to a Groovy Action the resulting code will be translated using SAM conversion that makes it possible to configure the extension using Kotlin lambda or Groovy closure.

Resolves: ExpediaGroup#893
smyrick pushed a commit that referenced this issue Oct 11, 2020
* [plugin] update Gradle plugin extension to use Actions

Originally extension was using Kotlin lambdas for some configuration which worked fine when used from Kotlin script (`build.gralde.kts`) but it could not be easily used from Groovy scripts (`build.gradle`). By changing from lambda with a receiver to a Groovy Action the resulting code will be translated using SAM conversion that makes it possible to configure the extension using Kotlin lambda or Groovy closure.

Resolves: #893

* fix ktlint violations
huehnerlady pushed a commit to huehnerlady/graphql-kotlin that referenced this issue Oct 16, 2020
)

* [plugin] update Gradle plugin extension to use Actions

Originally extension was using Kotlin lambdas for some configuration which worked fine when used from Kotlin script (`build.gralde.kts`) but it could not be easily used from Groovy scripts (`build.gradle`). By changing from lambda with a receiver to a Groovy Action the resulting code will be translated using SAM conversion that makes it possible to configure the extension using Kotlin lambda or Groovy closure.

Resolves: ExpediaGroup#893

* fix ktlint violations
dariuszkuc added a commit to dariuszkuc/graphql-kotlin that referenced this issue Aug 5, 2022
)

* [plugin] update Gradle plugin extension to use Actions

Originally extension was using Kotlin lambdas for some configuration which worked fine when used from Kotlin script (`build.gralde.kts`) but it could not be easily used from Groovy scripts (`build.gradle`). By changing from lambda with a receiver to a Groovy Action the resulting code will be translated using SAM conversion that makes it possible to configure the extension using Kotlin lambda or Groovy closure.

Resolves: ExpediaGroup#893

* fix ktlint violations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Development

Successfully merging a pull request may close this issue.

1 participant