smallrye-graphql: @link not working for quarkus

The GraphQL test works, so maybe the error is somewhere in quarkus/implementation-cdi? But I can not find it.

Quarkus is just the code start with enabled federation via application parameters. Furthermore, I added the @link like in the link tests.

@GraphQLApi
@Link(url = FEDERATION_SPEC_URL + "/v2.1", _import = { @Import(name = "@policy") })
public class HelloGraphQLResource {

in the Schema builder the link is not included, in the index view there is a link annotation. image image

While in the graphql test, we get the link from the index: image

Furthermore, as far as I understand it without the @link it is not federation v2, but with the recent changes it is neither v1. So federation is currently unusable.

@jmartisk could you have a look pls? Or maybe @RoKKim?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (12 by maintainers)

Most upvoted comments

I found problem. Quarkus smallrye graphql build not full index, and ignore some dirictives here. I did a quick fix.

To work with Apollo Rover, you need to add @Link, after which the general scheme was assembled.

@GraphQLApi
@Link(url = FEDERATION_SPEC_LATEST_URL, _import = {
        @Import(name = "@shareable"),
        @Import(name = "@external"),
        @Import(name = "@requires"),
        @Import(name = "@composeDirective"),
        @Import(name = "@extends"),
        @Import(name = "@authenticated"),
        @Import(name = "@inaccessible"),
        @Import(name = "@interfaceObject"),
        @Import(name = "@key"),
        @Import(name = "@override"),
        @Import(name = "@provides"),
        @Import(name = "@requiresScopes"),
        @Import(name = "@tag"),
        @Import(name = "@policy")
})
public class Api { .... }

@vitomanuguerrasoft

Hi. No, make one empty class that will contain @Link and that’s it. More than 1 time there will be an error. Here is a very primitive example of a federation that works with Apollo. https://github.com/RoMiRoSSaN/apollo-smallrye I have not worked with Apollo router (my choice fell on Wundergraph Cosmo), but everything seems to be assembled correctly.

I haven‘t tested it with multiple classes yet only with a simple example. Maybe @RoMiRoSSaN or @jmartisk can answer that.

I tried it right now, this is what happens in 3.15

schema @link(import : ["@key"], url : "https://specs.apollo.dev/federation/v2.7"){
  query: Query
}
.....

Just wanna add to this issue. We are having problems that I believe are caused by the lack of federation v2 support. We are getting the following build error in federation: Invalid definition for directive "@key": argument "fields" should have type "_FieldSet!" but found type "FieldSet!", which I believe is caused because of a federation v1 schema using a v2 FieldSet type. We have to use federation v2, and we also cannot get the @Link annotation working. @robp94 Did you find a workaround for adding this link, or did you do it manually in the schema (outside the generated one)?