Hi, we're wondering if anyone knows of a good Grap...
# graphql
d
Hi, we're wondering if anyone knows of a good GraphQL client for calling graphql endpoints? Ideally would generate types from the schema and simplify argument/variable passing
d
I think the most popular one is https://github.com/apollographql/apollo-android
ignore the name as it is not android specific
IMHO generated code is not that great (e.g. it would be nice to have some K data classes instead) but it is just a generated code
d
Thanks @Dariusz Kuc - does it need you to pull in the android plugin?
I think the kotlin data classes are experimental?
d
Oo thats new, didn't use it in a while
d
have you used it in a non android project?
d
you can either use apollo gradle plugin or open source maven plugin (use fork as original one is unsupported)
yes it works fine
in the end it just runs node module to download schema and generate the code
so technically you could just run npm directly (from a plugin)
d
oh I see, thanks!
d
looks like they still haven't fixed this though -> https://github.com/apollographql/apollo-android/issues/1042
a
Thanks Dariusz. Do you know if there is github link to the project which does not use the plugin, please?
d
you mean a project that use the plugin?
a
a project which does not use the plugin and uses only data classes.
d
you have to generate those classes somehow
technically graphql request is just a POST with
{ "query": "<your query>", "variables": {}, "operationName": "someName" }
*or get with query params
so you could easily manually craft those requests from code
that being said
by using apollo plugin you are getting type safety as generated types are based on your schema
a
Thanks Dariusz. We will give it a go.
m
Sorry just seeing this now. apollo-android works fine on non-android project, I've done that myself for a few projects. It does pull the android plugin in the buildscript classpath though. There's an issue open there for that and other plugin issue: https://github.com/apollographql/apollo-android/issues/817.
As for generated classes, they can now be generated in Kotlin with apollo.generateKotlinModels = true. IIRC, the generated code is using data classes
(which are not experimental anymore)