-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generateApolloSources fails with 4.0.1 and federation sub-graph graphqls #6221
Comments
Thanks for sending this 🙏 . This a side effect of #6164. Apollo Kotlin is now more strict about schema validation and throws on unknown directives. Since federation is transparent from a client point of view, I didn't add builtin support for the federation directives (unlike the nullability directives for an example). The immediate fix for this issue is to use the API schema SDL instead of the supergraph schema SDL. Something else we could consider is to ignore the federation directives altogether but that might become an issue the day we want to use In the meantime, can you try using the API schema? Is it an option for you? |
Hey @xcq1 👋 Did you get any luck with the API schema? We have a version around the corner and I'm trying to gauge how much of an issue this is. |
Thanks for the quick reply, and sorry for my delayed response. I don't think using an API SDL would be straightforward here. What I'm using here is not the supergraph definition, this is one subgraph definition in one spring-graphql server (of many) that is part of a federation. Apollo-kotlin is used in the integration tests in the CI pipeline. If I understand correctly, to get an API schema, I would need to start an ephemeral federation gateway instance with the new SDL polled in and then mock/prevent calls to other services. This seems a little bit excessive. If there was no other way, I think I'd probably rather port the old test code over to spring-graphql's testing solution, which appears to work fine with federation annotations. |
👋
May I ask how you get that SDL file? Even subgraphs should have different versions of the schema. There is:
(see also the full schema RFC) What you ideally need is a way to get 2. Introspection is a natural way to do that do you have an endpoint you can introspect maybe? |
To clarify, our current workflow looks like this:
So we essentially never come into contact with subgraph introspection. I looked into it and found spring-graphql actually provides a setting I'm open to practical suggestions, however, I'm not sure how easy it would be to configure the schema for apollo-kotlin in the build.gradle.kts from there. The testClasses requiring a download from a built artifact sounds like unnecessary complexity and potential increase in build time, or the introspection schema would need to be checked into the repo as a redundant duplicate that can potentially go out of sync during conflicts. I'm not sure which schema type is the one actually used with Rover/Federation? Of course it'd be better to test with that one, but I don't know of any significant difference between the two that would warrant that additional effort. |
Thanks for the details!
Interesting that this requires a network call. I would have expected a build time artifact, like graphql-kotlin is doing
Agreed. Let me dig a bit more into Spring/Rover/Federation, see if there's any solution and I'll report back. |
Hi @xcq1 👋 As a mitigation solution until the community gets to the bottom of this problem, I just released This Apollo Compiler Plugin patches the Apollo Kotlin compiler so that it knows about the federation directives. You can use it like so: apollo {
service("service") {
packageName.set("com.example")
plugin("com.apollographql.ffs:apollo-kotlin-ffs:0.0.0")
}
} Let me know how that works for you! |
Hey, thanks for the quick assistance. I can confirm this makes my tests work again with 4.0.1. The |
As a software developer, I figured out version numbers should be 0-indexed like everything else so I'm trying to start a trend 😄 . Just missed Halloween by a couple of days 🎃 I believe the long term solution is for server frameworks to have support for both SDL variants and formalize that in the spec. That might take a bit of time, let's see 🤞 |
I'll close this one and redirect to the full schemas RFC in case anyone is interested to join the discussion in the graphql working group. |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Kotlin usage and allow us to serve you better. |
Version
4.0.1
Summary
I'm using Apollo client to run tests against one of my federation sub-graph servers. For this the server's
.graphqls
looks like this:This worked fine with 4.0.0, but it suddenly throws an error in 4.0.1. According to all the docs I can find, this is the way you're supposed to include federation directives. The server works perfectly fine with the Apollo Gateway, so I don't think there is an error in the rest of the schema. Using the SDL also seems to be the preferred schema definition.
Steps to reproduce the behavior
Bump dependency version from 4.0.0 to 4.0.1
Logs
The text was updated successfully, but these errors were encountered: