Skip to content

Unable to upgrade to @apollo/gateway 2.x while keeping Federation 1 #3272

@sgarg7

Description

@sgarg7

Issue Description

I used rover to compose a supergraph schema from Federation 1, which is being hosted using apollo/gateway 2.x. According to the docs, apollo gateway should be able to upgrade without changing Federation 1 schema, but I run into errors when I start the gateway.

I created subgraphs to show this issue in the gist attached.

Link to Reproduction

https://gist.github.com/sgarg7/edbd1b4ef8e3b545226383bb563e3ef6

Reproduction Steps

  1. Run npm install
  2. Run node gateway.js and it will give the following error
~/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions