apollographql / federation-jvm

JVM support for Apollo Federation

Home Page:https://www.apollographql.com/docs/federation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Importing and renaming @key directive

RoKKim opened this issue · comments

Let's say I import the @key directive as @myKey:

extend schema @link(url: "https://specs.apollo.dev/federation/v2.5", import: [{name : "@key", as : "@myKey"}, "@requiresScopes", "Scope", "FieldSet"])

type Product @myKey(fields: "id") {
    id: ID!
    name: String!
    supplier: String @requiresScopes(scopes: [["scopeA"]])
}

In this scenario, the following code inside the com.apollographql.federation.graphqljava.SchemaTransformer#entityPredicate method will fail:
entityCandidate.getAllDirectivesByName().containsKey(FederationDirectives.keyName)

This occurs because FederationDirectives.keyName is hardcoded to "key". As a result, the _Entity will not be generated in the schema by the com.apollographql.federation.graphqljava.SchemaTransformer#build.