https://kotlinlang.org logo
#kgraphql
Title
# kgraphql
m

manlan

07/18/2020, 6:18 PM
Why is the error happening? I did define the variables in the query.
I defined LatLng in this way in the schema. It's a class from a different library that has lat and lng attributes. Is it the right way of defining the query variables?
j

jeggy

07/20/2020, 8:51 AM
seems weird. Is it because of radius is defined as int but you are providing a float?
m

manlan

07/20/2020, 4:53 PM
No, I defined it as a Double
But is my way of defining custom types and posting the objects correct?
j

jeggy

07/21/2020, 8:37 AM
If it's Double on the server, then you'll need to say it's Float when defining your query
on line 1 you have
$radius: Int
which should be
$radius: Float
m

manlan

07/21/2020, 9:40 AM
Still no luck 😐
j

jeggy

07/21/2020, 11:07 AM
Then it's probably something on the server? How does your
users
resolver look?
m

manlan

07/21/2020, 11:11 AM
j

jeggy

07/21/2020, 11:19 AM
found it
it's because of the fields are non optional but in your query definition it says optional. So to fix you should have this on line 1:
query ($radius: Float!, $location: LatLng!) {
if you tried to run the query you should have recieved this error:
Invalid variable $radius argument type Float, expected Float!
in Kotlin fields are non-nullable by default, but in GraphQL fields are nullable by default. so `Float`(in GraphQL) is the same as `Float?`(in Kotlin) and `Float!`(in GraphQL) is the same as
Float
(in Kotlin)
m

manlan

07/21/2020, 11:24 AM
Wow, thanks!! But strangely, the warning still shows
j

jeggy

07/21/2020, 11:25 AM
yeah, seems weird
where is this GraphQL playground hosted?
m

manlan

07/21/2020, 11:25 AM
message has been deleted
j

jeggy

07/21/2020, 11:25 AM
by the ktor plugin or some other online website?
m

manlan

07/21/2020, 11:26 AM
Ktor plugin
localhost
j

jeggy

07/21/2020, 11:26 AM
Then it should work. I will try and reproduce this locally. wait a minute
👍🏼 1
I tested it locally and am not getting this
could you open up the browser console and say what errors are shown there?
m

manlan

07/21/2020, 12:06 PM
message has been deleted
I was asking the same earlier, if I am defining and sending the custom types properly. The error seems to be due to this, as I feared. But now can you help with this?
j

jeggy

07/21/2020, 12:31 PM
Not sure, as it's hard to really understand the issue here without seeing the full code.
m

manlan

07/21/2020, 6:09 PM
This is basically the only code relevant, I believe
j

jeggy

07/21/2020, 8:48 PM
I think I found the issue here 🙂 https://github.com/aPureBase/KGraphQL/blob/master/kgraphql/src/main/kotlin/com/apurebase/kgraphql/schema/execution/ArgumentTransformer.kt#L29 As LatLng is a java class and does not have any primary constructor this line throws a null pointer exception
🙂 1
This is something that should work, so I will investigate further 👍
👍 1
3 Views