@apollo/federation-internals
Advanced tools
Comparing version 2.3.0-beta.3 to 2.3.0
@@ -5,2 +5,6 @@ # CHANGELOG for `@apollo/federation-internals` | ||
## 2.3.0 | ||
- Fix incorrect handling of `@external` on a type when dealing when adding `@shareable` during fed1 schema upgrades [PR #2343](https://github.com/apollographql/federation/pull/2343). | ||
## 2.2.1 | ||
@@ -7,0 +11,0 @@ |
@@ -328,3 +328,3 @@ "use strict"; | ||
if (!this._externalTester) { | ||
this._externalTester = new ExternalTester(this.schema); | ||
this._externalTester = new ExternalTester(this.schema, this.isFed2Schema()); | ||
} | ||
@@ -1219,4 +1219,5 @@ return this._externalTester; | ||
class ExternalTester { | ||
constructor(schema) { | ||
constructor(schema, isFed2Schema) { | ||
this.schema = schema; | ||
this.isFed2Schema = isFed2Schema; | ||
this.fakeExternalFields = new Set(); | ||
@@ -1264,2 +1265,5 @@ this.providedFields = new Set(); | ||
collectExternalsOnType() { | ||
if (!this.isFed2Schema) { | ||
return; | ||
} | ||
for (const type of this.schema.objectTypes()) { | ||
@@ -1266,0 +1270,0 @@ if (type.hasAppliedDirective(this.externalDirective)) { |
{ | ||
"name": "@apollo/federation-internals", | ||
"version": "2.3.0-beta.3", | ||
"version": "2.3.0", | ||
"description": "Apollo Federation internal utilities", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -248,1 +248,41 @@ import { FEDERATION2_LINK_WITH_FULL_IMPORTS } from '..'; | ||
}) | ||
test('handles the addition of @shareable when an @external is used on a type', () => { | ||
const s1 = ` | ||
type Query { | ||
t1: T | ||
} | ||
type T @key(fields: "id") { | ||
id: String | ||
x: Int | ||
} | ||
`; | ||
const s2 = ` | ||
type Query { | ||
t2: T | ||
} | ||
type T @external { | ||
x: Int | ||
} | ||
`; | ||
const subgraphs = new Subgraphs(); | ||
subgraphs.add(buildSubgraph('s1', 'http://s1', s1)); | ||
subgraphs.add(buildSubgraph('s2', 'http://s2', s2)); | ||
const res = upgradeSubgraphsIfNecessary(subgraphs); | ||
expect(res.errors).toBeUndefined(); | ||
// 2 things must happen here: | ||
// 1. the @external on type `T` in s2 should be removed, as @external on types were no-ops in fed1 (but not in fed2 anymore, hence the removal) | ||
// 2. field `T.x` in s1 must be marked @shareable since it is resolved by s2 (since again, it's @external annotation is ignored). | ||
const s2Upgraded = res.subgraphs?.get('s2')!; | ||
expect(s2Upgraded.schema.type('T')?.hasAppliedDirective('external')).toBe(false); | ||
const s1Upgraded = res.subgraphs?.get('s1')!; | ||
expect((s1Upgraded.schema.type('T') as ObjectType).field('x')?.hasAppliedDirective('shareable')).toBe(true); | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
34463
1
2017145
169