Skip to content

[generator] add runtime warning on deprecated context usage #1323

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

Merged
merged 4 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add function name and parent name to log message
  • Loading branch information
jbrwn committed Nov 24, 2021
commit 4b0f6e94396b8b4680efd4d73c7b2c7d99888a6b
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import kotlin.reflect.full.valueParameters

private val logger: Logger = LoggerFactory.getLogger("schemaGenerator")

internal fun KFunction<*>.getValidArguments(): List<KParameter> {
internal fun KFunction<*>.getValidArguments(parentName: String? = null): List<KParameter> {
return this.valueParameters.mapNotNull {
when {
it.isGraphQLIgnored() || it.isDataFetchingEnvironment() -> null
it.isGraphQLContext() -> {
logger.warn("GraphQLContext interface injection is deprecated. Please use DataFetchingEnvironment to retrieve ${it.getName()}.")
logger.warn("GraphQLContext interface injection is deprecated. Please use DataFetchingEnvironment to retrieve context. Parent: $parentName, function: ${getFunctionName()}, context: ${it.getName()}")
null
}
else -> it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal fun generateFunction(generator: SchemaGenerator, fn: KFunction<*>, pare
builder.withDirective(it)
}

fn.getValidArguments().forEach {
fn.getValidArguments(parentName).forEach {
builder.argument(generateArgument(generator, it))
}

Expand Down