apollographql / rover

The CLI for Apollo GraphOS
https://rover.apollo.dev
Other
407 stars 85 forks source link

"_FieldSet!" but found type "FieldSet!" #2126

Open vitomanuguerrasoft opened 1 week ago

vitomanuguerrasoft commented 1 week ago

I'm using the following versions:

federation_version: 2.9.0 rover: 0.26.2 router: 1.54.0

When running the command:

rover supergraph compose --config ./supergraph-config.yaml

I encounter this error:


DIRECTIVE_DEFINITION_INVALID: [xxxx] Invalid definition for directive "@key": argument "fields" should have type "_FieldSet!" but found type "FieldSet!"
DIRECTIVE_DEFINITION_INVALID: [xxxx] Invalid definition for directive "@requires": argument "fields" should have type "_FieldSet!" but found type "FieldSet!"
DIRECTIVE_DEFINITION_INVALID: [xxxx] Invalid definition for directive "@provides": argument "fields" should have type "_FieldSet!" but found type "FieldSet!"

For context, I'm generating my schema from a Quarkus application (3.14.2) using Smallrye GraphQL 2.9.2. According to the federation v2 documentation, it seems that the correct way to define FieldSet is without the underscore.

testingfrapochi commented 1 week ago

Same issue here.

dariuszkuc commented 1 week ago

Hello 👋 In fed v2 this scalar was renamed from _FieldSet to just FieldSet. We distinguish between v1 and v2 schemas by the presence of the @link directive that imports federation spec.

Based on the error I'm guessing you are not specifying the @link directive?

vitomanuguerrasoft commented 1 week ago

@dariuszkuc yes I have no link in my schema.graphql, how should it be defined?

dariuszkuc commented 1 week ago

In order to explicitly opt-in to fed v2 as a subgraph you need to add @link on the schema that links to a target federation version and can optionally imports some of the definitions (if you don't import those directives then they can still be used within your schema but they will have to be namespaced). See docs.

That being said, I am unsure what sort of compatibility SmallRye GraphQL offers as we don't have their example integration in our compatibility test repo. You can see the latest compatibility results here. I see there is an open issue to add example integration to test repo but that still hasn't happened. There is also an open issue around @link handling so I am unsure whether you can generate Fed v2 subgraphs using smallrye implementation.