Detecting unused query fields on clients

Hi folks,

I was curious if there are any solutions out there for clients (iOS / Android mainly) to help flag any unused query fields (i.e unused generated model types or fields).

I work in a large organization with lots of shared schema types, and it can be difficult to keep our client code clean.

For example, if we were to add a type to our schema as part of an A/B test, and then many months later go back and clean up the product code, we might forget to stop querying graphql for the fields.

I saw a similar thread here: Can we perform code inspection on generated code to find "unused declarations" · Issue #991 · apollographql/apollo-kotlin · GitHub.
We currently use Periphery to “lint” our codebase of unused declarations, but I wasn’t sure if this could be extended to the Apollo generated models or not.

Curious if anyone in the Apollo community has implemented anything for their own teams or projects.

The Apollo IntelliJ plugin has support for finding unused fields/operations.

1 Like

That is awesome. Advantage Android.

Any idea if there would be future support for something similar in Xcode? I know the plugin scene there is practically non-existent.

If you’re a GraphOS customer then you will have all this available in GraphOS Studio - docs. That will work across any and all clients.

You’re correct though that Xcode plugins are extremely limited in what we can do. We’re currently exploring other approaches that will allow us to move past those limitations though.