Hi everyone! :wave: I’m working on a use case inv...
# android
v
Hi everyone! 👋 I’m working on a use case involving a GraphQL query and encountering an issue related to Kotlin's string interpolation behavior. Here's a snippet for context:
Copy code
val FeedbackMutation = """mutation InsertFeedback($question2Rating: Int, $comment: String) {
  insert_feedback_one(object: {question2Rating: $question2Rating, comment: $comment}) {
    __typename
  }
}
"""
The problem arises because
$question2Rating
and
$comment
in the query conflict with Kotlin's string interpolation syntax. What’s the best way to handle such cases? Are there any workarounds you’d recommend for escaping or managing this behavior effectively?
And nop, \$ is not working
m
Copy code
"""I am a ${'$'} sign"""
v
Is this the only way ? (I'm already doing it, but it's not really readable)
m
Well, I guess that's what the proposal is about
You can always define a toplevel constant and do
Copy code
"""I am a $dollar sign"""
But it's the same thing really
1
TBH I don't mind too much. Even if the proposal was implemented, I'd probably keep
${'$'}
v
Thanks, I will keep it like that until maybe an evolution