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
.
Seems like we need similar or expose imports from LinkDirectiveProcessor
https://github.com/apollographql/federation-jvm/blob/main/graphql-java-support/src/main/java/com/apollographql/federation/graphqljava/directives/LinkDirectiveProcessor.java#L123