# ReferenceContributor doesn't work for GraphQL language

**URL:** <https://platform.jetbrains.com/t/referencecontributor-doesnt-work-for-graphql-language/1485>\
**Category:** IntelliJ Platform\
**Created:** [April 24, 2025, 2:23pm UTC](https://platform.jetbrains.com/t/referencecontributor-doesnt-work-for-graphql-language/1485 "2025-04-24T14:23:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bohdan.harniuk](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/bohdan.harniuk/32/147_2.png) [@bohdan.harniuk](https://platform.jetbrains.com/u/bohdan.harniuk)\
**Post date:** [April 24, 2025, 2:23pm UTC](https://platform.jetbrains.com/t/referencecontributor-doesnt-work-for-graphql-language/1485/1 "2025-04-24T14:23:49Z")

</div>

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](https://github.com/JetBrains/js-graphql-intellij-plugin/blob/master/src/main/com/intellij/lang/jsgraphql/ide/resolve/GraphQLReferenceService.java#L78). 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.

---

<div class="post-metadata">

**Author:** ![yuriy.artamonov](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/yuriy.artamonov/32/48_2.png) [@yuriy.artamonov](https://platform.jetbrains.com/u/yuriy.artamonov)\
**Post date:** [April 25, 2025, 6:40pm UTC](https://platform.jetbrains.com/t/referencecontributor-doesnt-work-for-graphql-language/1485/2 "2025-04-25T18:40:37Z")

</div>

> [@bohdan.harniuk](#):
>
> Could someone advise on how to provide custom references in such cases, where the language does not allow attaching them via `ReferenceContributor`?

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

---

<div class="post-metadata">

**Author:** ![bohdan.harniuk](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/bohdan.harniuk/32/147_2.png) [@bohdan.harniuk](https://platform.jetbrains.com/u/bohdan.harniuk)\
**Post date:** [April 25, 2025, 8:27pm UTC](https://platform.jetbrains.com/t/referencecontributor-doesnt-work-for-graphql-language/1485/3 "2025-04-25T20:27:11Z")

</div>

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.
