Apollo-android: Wrong indentation of generated code causes a compilation error

Created on 16 Apr 2020  路  2Comments  路  Source: apollographql/apollo-android

Summary
A wrong indentation in generated classes causes a compilation error.

Description
Apollo 1.4.4 generates a function Mapper() and indents its content in a wrong way when the generic type is too long.
Example:

@Suppress("FunctionName")
fun Mapper(): ResponseFieldMapper<VeryVeryLongMutationTypeOrQueryTypeHere> = ResponseFieldMapper
    { invoke(it) } // This is actually on a new line but should be in the previous one

The compilation error is Expecting member declaration on ResponseFieldMapper.
By moving the { invoke(it) } next to ResponseFieldMapper, the error disappears.

Version
Introduced in 1.4.4.
Apollo 1.4.3 does not generate the Mapper() function, so there is no compilation error.

compiler Bug

Most helpful comment

I'm looking into this. This looks like it is out of our control. It might a bug in KotlinPoet.

All 2 comments

I'm looking into this. This looks like it is out of our control. It might a bug in KotlinPoet.

No it is not. As it is mentioned here, there is a way to control the wrapping. Doing a fix now. https://github.com/square/kotlinpoet/issues/695

Was this page helpful?
0 / 5 - 0 ratings