Skip to content

Commit

Permalink
[federation] fix fed2 link directive imports and spec URL (#1593)
Browse files Browse the repository at this point in the history
All directive names should be prefixed with `@` as otherwise it leads to composition errors.
  • Loading branch information
dariuszkuc authored Nov 7, 2022
1 parent 2fbb97f commit eab7476
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
schema @link(url : "https://specs.apollo.dev/link/v1.0/") @link(import : ["extends", "external", "inaccessible", "key", "link", "override", "provides", "requires", "shareable", "tag", "_FieldSet"], url : "https://www.apollographql.com/docs/federation/federation-spec/"){
schema @link(import : ["@extends", "@external", "@inaccessible", "@key", "@override", "@provides", "@requires", "@shareable", "@tag", "_FieldSet"], url : "https://specs.apollo.dev/federation/v2.0"){
query: Query
mutation: Mutation
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ open class FederatedSchemaGeneratorHooks(private val resolvers: List<FederatedTy

override fun willBuildSchema(builder: GraphQLSchema.Builder): GraphQLSchema.Builder {
if (optInFederationV2) {
val fed2Imports = federatedDirectiveV2List.map { it.name }
val fed2Imports = federatedDirectiveV2List.map { "@${it.name}" }
.minus("@$LINK_DIRECTIVE_NAME")
.plus(FIELD_SET_SCALAR_NAME)

builder.withSchemaDirective(LINK_DIRECTIVE_TYPE)
.withSchemaAppliedDirective(appliedLinkDirective(LINK_SPEC_URL))
.withSchemaAppliedDirective(appliedLinkDirective(FEDERATION_SPEC_URL, fed2Imports))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import graphql.schema.GraphQLArgument
import graphql.schema.GraphQLList

const val LINK_SPEC_URL = "https://specs.apollo.dev/link/v1.0/"
const val FEDERATION_SPEC_URL = "https://www.apollographql.com/docs/federation/federation-spec/"
const val FEDERATION_SPEC_URL = "https://specs.apollo.dev/federation/v2.0"

/**
* ```graphql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FederatedSchemaV2GeneratorTest {
fun `verify can generate federated schema`() {
val expectedSchema =
"""
schema @link(url : "https://specs.apollo.dev/link/v1.0/") @link(import : ["extends", "external", "inaccessible", "key", "link", "override", "provides", "requires", "shareable", "tag", "_FieldSet"], url : "https://www.apollographql.com/docs/federation/federation-spec/"){
schema @link(import : ["@extends", "@external", "@inaccessible", "@key", "@override", "@provides", "@requires", "@shareable", "@tag", "_FieldSet"], url : "https://specs.apollo.dev/federation/v2.0"){
query: Query
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type SelfReferenceObject {

const val FEDERATED_SERVICE_SDL_V2 =
"""
schema @link(url : "https://specs.apollo.dev/link/v1.0/") @link(import : ["extends", "external", "inaccessible", "key", "link", "override", "provides", "requires", "shareable", "tag", "_FieldSet"], url : "https://www.apollographql.com/docs/federation/federation-spec/"){
schema @link(import : ["@extends", "@external", "@inaccessible", "@key", "@override", "@provides", "@requires", "@shareable", "@tag", "_FieldSet"], url : "https://specs.apollo.dev/federation/v2.0"){
query: Query
}
Expand Down

0 comments on commit eab7476

Please sign in to comment.