Let’s assume the following example while using v2 of all the nifty apollo npm packages
# subgraph A
type Customer @key(fields: "id") {
id: Int!
name: String!
}
type Query {
customer(id: Int!): Customer
}
# subgraph B
type Invoice @key(fields: "id") {
id: Int!
amount: Int!
}
type Customer @key(fields: "id") {
id: Int!
invoices: [Invoice!]!
}
my problem is, if I only use this, buildSchema will assume fed1 and so will decide on a query plan that might be pointing at subgraph B because it cannot make out the correct one.
ok no problem, when I try to add
to have fed2 version of @key directive for example I get this conflicting error
Invalid definition for directive "@key": argument "fields" should have type "federation__FieldSet!" but found type "_FieldSet!"
Invalid definition for directive "@requires": argument "fields" should have type "federation__FieldSet!" but found type "_FieldSet!"
I can then add the directive explicitly but it will always errors on not having the other of the possible fieldset options.
Obviously, when I let the gateway only have one graph the resolution works as expected, as soon as the gateway catches wind on the extension of the type sin subgraph b it breaks.
do I need to specify the fed version in every subgraph?
if I have a modular subgraph, do I have to specify it in every partial of a subgraph?
Since I only get UNKNOWN error in rover, is there an error message for federation version mismatch?
I’m getting almost the same error, except with the inverse expectation, when trying to publish a fed2 subgraph (i.e. one containing extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key", "@shareable"]) in its schema) to a fed2.1 supergraph:
Invalid definition for directive "@key": argument "fields" should have type "_FieldSet!" but found type "federation__FieldSet!"
this is a brand spanking new supergraph, into which i’m trying to publish my first subgraph, so my issue can’t be related to merging conflicts between subgraphs. i even tried changing the @link directive to reference ".../federation/v2.1", even though i don’t see that as a documented option anywhere, but it made no difference. not sure how to fix this.
my supergraph is named mike-z-test in case an apollo dev wants to check it out.
What are the subgraph libraries you’re using for the two subgraphs that won’t compose? It sounds like maybe there’s some incompatibility we should look into.
Are you able to share some code that reproduces this error?
depending how you got your schema together, my initial mistake was that I used graphql code generator and had some unrelated non fed graphql files involved even complete schemas, thanks to globs
my initial mistake was that I used graphql code generator […]
oooh i’m using that too, thanks for chiming in, that gives me a thread to pull on!
@dylan it’s not that two subgraphs won’t compose, i can’t even publish a single subgraph into an empty supergraph. i’m gonna look into the code gen stuff and report back.