问题
I've generated the Apollo classes successfully and can see them in the build directory, however they're not available on the classpath. Strangely the Enum that is generated is available but the classes themselves aren't.
Running the sample project provided on Apollo's Github does work but I cant see the difference between the configurations.
mcve below.
https://github.com/michaeljq/graphQlMCVE
回答1:
Right now, you have src/main/graphql/
containing GraphQL documents. That means that your Java classes will be generated with no Java package, which probably is not what you want.
Instead, create a package tree under src/main/graphql/
(e.g., src/main/graphql/apollotest/mq/apollotest/api/
). Move the GraphQL documents and schema.json
there. Clean the project, and you should find that your Apollo-generated classes are available to you in whatever Java package you chose (e.g., apollotest.mq.apollotest.api
in the above example).
回答2:
Here is a screenshot to understand the solution faster:
来源:https://stackoverflow.com/questions/44141835/apollo-android-client-cannot-access-generated-classes-on-classpath