Make the federation v2 version configurable, federation v2.5 is still experimental
roookeee opened this issue · comments
Is your feature request related to a problem? Please describe.
We upgraded to graphql-kotlin 7.0 which forces federation v2.5
which is currently still marked experimental in Apollo Studio and thus not usable for us in production:
We cannot migrate to Spring Boot 3 or graphql-kotlin 7.x while this problem persists, there is no ETA when federation 2.5 will be non-experimental
Describe the solution you'd like
Allow us to configure the federation version to include in the auto-generated @link
directive.
Describe alternatives you've considered
Downgrading to graphql-kotlin 6.x or generating the customized @link
directive ourselves, both are error prone or block us from using Spring Boot 3.x.
Hello 👋
As you mentioned in the alternatives - while we default to auto-import latest supported version (2.5 at the moment), starting with version 6 you can specify custom @link
directive on your schema and opt-in to any version. In v7 you can also namespace/rename the imports
@Component
@LinkDirective(url = "https://specs.apollo.dev/federation/v2.4", `as` = "federation", import = [LinkImport("@key")])
class MyCustomSchema : Schema
Note that by specifying custom @link
directive we no longer auto-import directives, so if they are not explicitly included in the imports
then they will be namespaced with federation__
prefix. See @link
directive docs for details.
As you state yourself we are losing some functionality when going this way, can you elaborate the reasoning behind forcing an experimental version like this ? Also, why not allow us to downgrade to a prior minor version? Right now its a constant value that we can't change without learning about the intricacies of this library, let alone the loss of automatic functionality which we didn't need to know about. Thank your for your time!
There is no loss of functionality.
can you elaborate the reasoning behind forcing an experimental version like this ?
I believe the only experimental/preview feature of Federation v2.5 are the new auth features of the router. Query planner/composition logic is stable and federation v2.5.5 is the latest available version.
why not allow us to downgrade to a prior minor version?
You can downgrade (or even upgrade in the future) by applying custom @link
directive.
When generating federated schemas, we auto apply @link
directive with all federation imports (ones used in the schema and up to version 2.3) so there is no renaming/namespacing of the elements. When you apply custom @link
directive you explicitly import elements and non-imported elements get namespaced to the imported spec.
While generated SDL might be different (e.g. if you use @key
directive in your schema but explicitly don't import it, it will be renamed to @federation__key
), from composition perspective both schemas will be semantically the same.
To close the loop -> Apollo Federation v2.5 is now GA (no longer experimental) in studio
While we are still waiting for our production Apollo Federation to update to 2.5, I wanted to list issues other people might run into:
- We are running into a gradle build error when prefixing
url
in@LinkDirective
withhttps://
on windows only, CI (Linux) builds without issues. Rover forces us to prefix withhttps://
, thus our workaround is not mergeable:
@Component
@LinkDirective(
url = "https://specs.apollo.dev/federation/v2.4",
`as` = "federation",
import = [
LinkImport("@key"),
LinkImport("FieldSet")
]
)
class FederatedSchema : Schema
- We have to disable
kapt
(which we need for some Spring Boot stuff) as the@LinkDirective
usesimport
as a field name which is a reserved keyword in Java. Askapt
generates compatibility annotation Java files, this breaks compilation. We don't want to losekapt
and thus our workaround is not mergeable
=> We will have to wait for our prod env to update to 2.5 which might take some time.
Can you provide a repo with a repro? Otherwise it is hard to figure out what is the underlying issue.
re: windows and illegal :
char -> AFAIK that is illegal character for file/folder names, it is a string within a file so something sounds iffy to me
re: kapt
- @LinkDirective
was using the import
field in pre v7 as well, guessing the exception is from explicitly using it in your project. Not familiar with kapt
so unsure if it is possible but instead of disabling kapt
is there a way to selectively ignore classes from kapt
(well the annotation processor invoked by kapt) compilation?