Naming Convention for generated Classes in Apollo Android Client

Team,
I am using the Apollo Android Client and i came across a problem/possibly a bug in the names of the generated classes.

So what i found so far that if i right a query

query LaunchDetails($id:ID!) {
    launch(id: $id) {
        id
        site
        mission {
            name
            missionPatch(size:LARGE)
        }
    }
}

The corresponding class file is generated with the name LaunchDetailsQuery i.e it has added the Query Suffix after LaunchDetails

however if i write a query which ends with Query, it doesn’t add an additional Query suffix to the class

eg if i write

query TestQuery($id:ID!) {
    launch(id: $id) {
        id
        site
    }
}

the corresponding generated class file will be TestQuery only

Please see the generated class files snapshot.

Similar behaviour is with Mutation as well.
Wanted to know how the naming convention is decided for generating classes. I initially assumed that we will be suffixing Query and Mutation to the corresponding [query/mutation] name. But that is not always true.

Hi :wave:

This is actually on purpose. Suffixing with Query is usually a nice naming convention, and that’s why it’s done automatically - unless the name already has it.

That being said, it is also possible to disable this behavior like so:

apollo {
  useSemanticNaming.set(false)
}
1 Like

Thank You @Benoit_Lubek , this is useful. It worked well