# Upgrading to @apollo/gateway 2.x while keeping Federation 1

**URL:** https://community.apollographql.com/t/upgrading-to-apollo-gateway-2-x-while-keeping-federation-1/8702
**Category:** Router
**Tags:** federation
**Created:** [March 12, 2025, 9:03pm UTC](https://community.apollographql.com/t/upgrading-to-apollo-gateway-2-x-while-keeping-federation-1/8702 "2025-03-12T21:03:18Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![sgarg7](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sgarg7/32/5883_2.png) [@sgarg7](https://community.apollographql.com/u/sgarg7)
#### Post date: [March 12, 2025, 9:03pm UTC](https://community.apollographql.com/t/upgrading-to-apollo-gateway-2-x-while-keeping-federation-1/8702/1 "2025-03-12T21:03:18Z")

</div>

I’m performing an overdue upgrade of @apollo/gateway 0.x to 2.x, while keeping Federation 1 to keep it simple and incremental, then eventually upgrade to Federation 2.

I’m not sure if I’m missing some syntax to force the gateway to use federation 1, but I’m getting errors similar to the following when composing using a list of subgraph endpoints.

```auto
On field "Person.name", for @provides(fields: "Id name emailAddress "): field Person.name cannot be included because it has arguments (fields with argument are not allowed in @provides)

```

Is there a specific version of @apollo/gateway upto which Federation 1 is supported?  
What’s the syntax to force using Federation 1 in @apollo/gateway ?

The page that mentions the backwards compatibility, but I can’t find more information.

> **[Backward Compatibility in Apollo Federation 2](https://www.apollographql.com/docs/graphos/reference/migration/backward-compatibility#does-apollogateway-v2-support-federation-1)**
>
> Frequently asked questions when transitioning from Apollo Federation 1 to Federation 2.

---

<div class="post-metadata">

### Author: ![shanemyrick](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/shanemyrick/32/5474_2.png) [@shanemyrick](https://community.apollographql.com/u/shanemyrick)
#### Post date: [March 12, 2025, 10:00pm UTC](https://community.apollographql.com/t/upgrading-to-apollo-gateway-2-x-while-keeping-federation-1/8702/2 "2025-03-12T22:00:32Z")

</div>

> [@sgarg7](#):
>
> en composing using a list of subgraph endpoints

Gateway v2.x supports both Fed 1 (aka 0.x) and Fed 2. There is no “mode” you have to put the gateway in because what determines what Federation version you use is your supergraph file which is the output from composition at build time.

I would recommend using `rover supergraph compose` to build this file.

```yaml
federation_version: 1
subgraphs:
  foobar:
    routing_url: http://localhost:4001/graphql
    schema:
      file: schema.graphql

```

Your error that you are seeing is an error because the `@provides` directive can not resolve fields that require arguments dynamically. See your error message:

```auto
Person.name cannot be included because it has arguments (fields with argument are not allowed in @provides)

```

---

<div class="post-metadata">

### Author: ![sgarg7](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sgarg7/32/5883_2.png) [@sgarg7](https://community.apollographql.com/u/sgarg7)
#### Post date: [March 13, 2025, 2:03am UTC](https://community.apollographql.com/t/upgrading-to-apollo-gateway-2-x-while-keeping-federation-1/8702/3 "2025-03-13T02:03:42Z")

</div>

Thanks for the reply. I don’t get the @provides error with apollo gateway 0.x, but I do with 2.x.  
To fix the error by removing the argument will be a breaking change, while its mentioned that upgrading the gateway should be backward compatible. Is there no way to avoid / override the error and proceed with the same schema?

---

<div class="post-metadata">

### Author: ![shanemyrick](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/shanemyrick/32/5474_2.png) [@shanemyrick](https://community.apollographql.com/u/shanemyrick)
#### Post date: [March 13, 2025, 9:52pm UTC](https://community.apollographql.com/t/upgrading-to-apollo-gateway-2-x-while-keeping-federation-1/8702/4 "2025-03-13T21:52:05Z")

</div>

You will need to compose your supergraph with Federation 1 and then you can pass that Fed 1 supergraph to Gateway 2.x

---

<div class="post-metadata">

### Author: ![sgarg7](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sgarg7/32/5883_2.png) [@sgarg7](https://community.apollographql.com/u/sgarg7)
#### Post date: [March 17, 2025, 12:04pm UTC](https://community.apollographql.com/t/upgrading-to-apollo-gateway-2-x-while-keeping-federation-1/8702/5 "2025-03-17T12:04:11Z")

</div>

I tried that. Rover is able to compose the supergraph, but I get the same federation 2 validation errors when using @apollo/gateway 2.x with the supergraph file, as when I had used composition with @apollo/gateway 2.x directly

KEY\_FIELDS\_HAS\_ARGS  
KEY\_INVALID\_FIELDS  
PROVIDES\_FIELDS\_HAS\_ARGS  
PROVIDES\_INVALID\_FIELDS

---

<div class="post-metadata">

### Author: ![shanemyrick](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/shanemyrick/32/5474_2.png) [@shanemyrick](https://community.apollographql.com/u/shanemyrick)
#### Post date: [March 17, 2025, 3:58pm UTC](https://community.apollographql.com/t/upgrading-to-apollo-gateway-2-x-while-keeping-federation-1/8702/6 "2025-03-17T15:58:05Z")

</div>

@sgarg7 You should not be getting Fed 2 composition errors if you are using Fed 1 as your `federation_version` in the supergraph config.

> **[Rover supergraph Commands](https://www.apollographql.com/docs/rover/commands/supergraphs#yaml-configuration-file)**
>
> Learn Rover CLI commands for fetching, composing, and managing supergraphs within federated GraphQL architectures.

Can you please make sure that you are setting that up all correctly and then if it still is not working share your files here for reproduction.

---

<div class="post-metadata">

### Author: ![sgarg7](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sgarg7/32/5883_2.png) [@sgarg7](https://community.apollographql.com/u/sgarg7)
#### Post date: [March 18, 2025, 2:39pm UTC](https://community.apollographql.com/t/upgrading-to-apollo-gateway-2-x-while-keeping-federation-1/8702/7 "2025-03-18T14:39:48Z")

</div>

Yes, I’m using the `--federation-version 1` cli option and also the supergraph config file option for rover.  
It’s not the `rover supergraph compose..` command that gives errors, it’s running the gateway using `@apollo/gateway` using the generated supergraph file that gives me one error right now, and I believe it will return the other errors also mentioned above, once I fix this one.  
Out of them, I think the `PROVIDES_FIELDS_HAS_ARGS` error needs a schema fix that can break existing queries.

I’ll come up with a representative schema that returns the same errors when run with the gateway.

```auto
Gateway successfully initialized (but not yet loaded)
Loading gateway...
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

GraphQLError: Invalid empty selection set for field "ServiceHours.hours" of non-leaf type [ServiceHoursTime!]!

```

---

<div class="post-metadata">

### Author: ![sgarg7](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sgarg7/32/5883_2.png) [@sgarg7](https://community.apollographql.com/u/sgarg7)
#### Post date: [April 9, 2025, 7:16pm UTC](https://community.apollographql.com/t/upgrading-to-apollo-gateway-2-x-while-keeping-federation-1/8702/8 "2025-04-09T19:16:10Z")

</div>

apologies, haven’t gotten back to this, will send a reproducible schema when I do.

---

<div class="post-metadata">

### Author: ![sgarg7](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sgarg7/32/5883_2.png) [@sgarg7](https://community.apollographql.com/u/sgarg7)
#### Post date: [June 2, 2025, 9:15pm UTC](https://community.apollographql.com/t/upgrading-to-apollo-gateway-2-x-while-keeping-federation-1/8702/9 "2025-06-02T21:15:05Z")

</div>

Created a minimal reproduction schema for this issue here

> <https://gist.github.com/sgarg7/edbd1b4ef8e3b545226383bb563e3ef6>
>
> There are more than three files. show original

The supergraph has been composed with  
`rover supergraph compose --config supergraph-config.yaml --federation-version 1 > supergraph.schema.graphql`

_this does not generate composition errors but running node gateway.js shows the following error -_

```auto
❯ node gateway.js 
~/test-schema/node_modules/@apollo/federation-internals/dist/extractSubgraphsFromSupergraph.js:201
            throw new Error(`${msg}.\n\nDetails:\n${errorToString(error)}`);
                  ^

Error: Error extracting subgraph "accounts" from the supergraph: this might be due to errors in subgraphs that were mistakenly ignored by federation 0.x versions but are rejected by federation 2.
Please try composing your subgraphs with federation 2: this should help precisely pinpoint the problems and, once fixed, generate a correct federation 2 supergraph.

Details:
[accounts] On type "User", for @key(fields: "id(format:\"uuid\")"): field User.id cannot be included because it has arguments (fields with argument are not allowed in @key)
    at extractSubgraphsFromSupergraph (~/test-schema/node_modules/@apollo/federation-internals/dist/extractSubgraphsFromSupergraph.js:201:19)
    at Supergraph.subgraphs (~/test-schema/node_modules/@apollo/federation-internals/dist/supergraphs.js:137:107)
    at buildFederatedQueryGraph (~/test-schema/node_modules/@apollo/query-graphs/dist/querygraph.js:259:34)
    at new QueryPlanner (~/test-schema/node_modules/@apollo/query-planner/dist/buildPlan.js:1785:80)
    at ApolloGateway.updateWithSchemaAndNotify (~/test-schema/node_modules/@apollo/gateway/dist/index.js:436:29)
    at ApolloGateway.updateWithSupergraphSdl (~/test-schema/node_modules/@apollo/gateway/dist/index.js:416:18)
    at ApolloGateway.externalSupergraphUpdateCallback (~/test-schema/node_modules/@apollo/gateway/dist/index.js:366:18)
    at ApolloGateway.initializeSupergraphManager (~/test-schema/node_modules/@apollo/gateway/dist/index.js:338:18)
    at async ApolloGateway.load (~/test-schema/node_modules/@apollo/gateway/dist/index.js:244:13)
    at async SchemaManager.start (~/test-schema/node_modules/@apollo/server/dist/cjs/utils/schemaManager.js:37:28)

Node.js v20.14.0

```

This is the `KEY_FIELDS_HAS_ARGS` error

Notice the line

> his might be due to errors in subgraphs that were mistakenly ignored by federation 0.x versions but are rejected by federation 2.

this also means the gateway is trying to parse the schema as federation 2 not federation 1 or 0.x

---

<div class="post-metadata">

### Author: ![shanemyrick](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/shanemyrick/32/5474_2.png) [@shanemyrick](https://community.apollographql.com/u/shanemyrick)
#### Post date: [June 9, 2025, 6:59pm UTC](https://community.apollographql.com/t/upgrading-to-apollo-gateway-2-x-while-keeping-federation-1/8702/10 "2025-06-09T18:59:42Z")

</div>

@sgarg7 Thank you for sharing the reproduction. That was much easier to find an answer. It appears you have uncovered an edge case and something that arose from our migration from Fed 1 to 2.

This scenario was techinically not supported in Fed 1 but just not caught by composition. In Fed 1 we just never had any checks for this scenario and since it was already in place we couldn’t break schemas without asking you to update to Fed 2.

Since the key value parsing requires some args it does not guarentee that value is the same even if hardcoded. This is not allowed in Fed 2 as it makes query planning “guaranteed” to be deterministic. This does need to be indicated in the migration docs.

To fix this, you are going to have to add a new key that does not require any args. Since this is a static value that you pass in it should be easy enough to add a new field that on the backend does the same logic always with “uuid” as the format

---

<div class="post-metadata">

### Author: ![shanemyrick](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/shanemyrick/32/5474_2.png) [@shanemyrick](https://community.apollographql.com/u/shanemyrick)
#### Post date: [June 9, 2025, 7:07pm UTC](https://community.apollographql.com/t/upgrading-to-apollo-gateway-2-x-while-keeping-federation-1/8702/11 "2025-06-09T19:07:25Z")

</div>

> **[Backward Compatibility in Apollo Federation 2](https://www.apollographql.com/docs/graphos/schema-design/federated-schemas/reference/backward-compatibility#breaking-changes)**
>
> Frequently asked questions when transitioning from Apollo Federation 1 to Federation 2.
