federation icon indicating copy to clipboard operation
federation copied to clipboard

Using the `key` directive automatically defines types as extensions

Open vinaybedre opened this issue 3 years ago • 3 comments

  • [x] A short, but descriptive title. The title doesn't need "Apollo" in it.

  • As soon an ObjectType is added a directed with key in it, apollo federation picks up as extensions and complains that there is no type definition for in any subgraph

  • [X] When a published package is being used, the package management system Can be seen in repo shared below

  • [X] The expected behavior. Federation should allow pickup those object types which are just defined with key directive and should not complain object definition is missing.

  • [X] The actual behavior. Federation throws error as soon an object type is defined with key directive that that definition is missing.

  • [X] A simple, runnable reproduction!

https://github.com/vinaybedre/federation-error

  • [X] The federation version you are targeting.

vinaybedre avatar May 13 '22 14:05 vinaybedre

I created new issue. But this issue probably has easier reproduction: https://github.com/apollographql/federation/issues/3023

developer239 avatar Jun 03 '24 10:06 developer239

Is anyone even using the federation?

developer239 avatar Jun 03 '24 10:06 developer239

I decided to patch this file and call it a day. The bug is likely not caused here but by @Directive('@key(fields: "id")') directive - either the decorator is problematic or the underlying tech.

`--- node_modules/@apollo/federation-internals/dist/schemaUpgrader.js.bak    2024-06-03 14:05:31
+++ node_modules/@apollo/federation-internals/dist/schemaUpgrader.js    2024-06-03 14:05:54
@@ -286,7 +286,7 @@
                 return;
             }
         }
-        this.addError(error_1.ERRORS.EXTENSION_WITH_NO_BASE.err(`Type "${type}" is an extension type, but there is no type definition for "${type}" in any subgraph.`, { nodes: extensionAST }));
+        // this.addError(error_1.ERRORS.EXTENSION_WITH_NO_BASE.err(`Type "${type}" is an extension type, but there is no type definition for "${type}" in any subgraph.`, { nodes: extensionAST }));
     }
     preUpgradeValidations() {
         for (const type of this.schema.types()) {
`

developer239 avatar Jun 03 '24 12:06 developer239