ReferenceContributor doesn't work for GraphQL language

I tried to provide references from the schema.graphqls files to the corresponding classes (framework-dependent elements). However, the GraphQL plugin uses its own reference resolution mechanism there, and only the already supported PSI elements have reference resolution in that file, as seen in GraphQLReferenceService. I attempted to add support for custom elements via ReferenceContributor, but it doesn’t work the same way because the GraphQL plugin doesn’t use something like ReferenceProvidersRegistry.getReferencesFromProviders(this).

I managed to get it working using the lang.directNavigationProvider extension point. However, it is marked as @Experimental, so I assume it’s not the best idea to rely on it just yet.

Could someone advise on how to provide custom references in such cases, where the language does not allow attaching them via ReferenceContributor?

As a fallback, I’ll use the codeInsight.lineMarkerProvider extension point. However, references are more appropriate in this context. I also want class references from GraphQL files to be recognized as used, to enable navigation back to their usages, and to ensure FQNs in GraphQL files are renamed automatically when the class is renamed.

There is no such way. Probably the best thing one can do is to contribute code that will enable references in some places to the original language plugin

Thank you for your answer!

It sounds interesting. I will start by providing navigation support via line markers, and maybe I will find time to contribute later.

Can you advise me on how I can mark a class as used when navigation in both directions is provided via line markers?

I see only one way to highlight such classes as used - by implementing an implicit usage provider. But I might be wrong.