@apollo/federation
Advanced tools
Comparing version 0.21.0 to 0.21.1
@@ -7,2 +7,6 @@ # CHANGELOG for `@apollo/federation` | ||
- Ignore thrown errors from `extendSchema` during composition (these particular errors are already validated against and returned as composition errors) [PR #478](https://github.com/apollographql/federation/pull/478) | ||
## v0.21.0 | ||
- __BREAKING__: Drop support for Node.js 8 and Node.js 10. This package now only targets Node.js 12+ LTS (Long-Term Support) versions, the same as `@apollo/gateway`, which first received this treatment in https://github.com/apollographql/apollo-server/pull/4031. Node.js 8 has already lapsed from the [Node.js Foundation's LTS schedule](https://github.com/nodejs/release) and Node.js 10 (in _Maintenance LTS_ right now) is targeted to be end-of-life'd (EOL) at the end of April 2021. [PR #311](https://github.com/apollographql/federation/pull/311) | ||
@@ -9,0 +13,0 @@ - Export `GraphQLSchemaModule` type. [PR #293](https://github.com/apollographql/federation/pull/293) |
@@ -183,3 +183,8 @@ "use strict"; | ||
errors = validate_1.validateSDL(definitionsDocument, schema, rules_1.compositionRules); | ||
schema = graphql_1.extendSchema(schema, definitionsDocument, { assumeValidSDL: true }); | ||
try { | ||
schema = graphql_1.extendSchema(schema, definitionsDocument, { | ||
assumeValidSDL: true, | ||
}); | ||
} | ||
catch (e) { } | ||
const extensionsDocument = { | ||
@@ -190,3 +195,8 @@ kind: graphql_1.Kind.DOCUMENT, | ||
errors.push(...validate_1.validateSDL(extensionsDocument, schema, rules_1.compositionRules)); | ||
schema = graphql_1.extendSchema(schema, extensionsDocument, { assumeValidSDL: true }); | ||
try { | ||
schema = graphql_1.extendSchema(schema, extensionsDocument, { | ||
assumeValidSDL: true, | ||
}); | ||
} | ||
catch { } | ||
schema = new graphql_1.GraphQLSchema({ | ||
@@ -243,2 +253,4 @@ ...schema.toConfig(), | ||
const field = namedType.getFields()[fieldName]; | ||
if (!field) | ||
break; | ||
const fieldFederationMetadata = { | ||
@@ -245,0 +257,0 @@ ...utils_1.getFederationMetadata(field), |
{ | ||
"name": "@apollo/federation", | ||
"version": "0.21.0", | ||
"version": "0.21.1", | ||
"description": "Apollo Federation Utilities", | ||
@@ -32,3 +32,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "35ec7b0ad28a383d39a42de1f75158f2f017d80f" | ||
"gitHead": "7d2fdda2acf8660db59a328870e6f853c856f9b6" | ||
} |
@@ -19,2 +19,3 @@ import { composeAndValidate } from '../composeAndValidate'; | ||
compositionHasErrors, | ||
CompositionResult, | ||
} from '../utils'; | ||
@@ -163,2 +164,42 @@ | ||
it("doesn't throw errors when a type is unknown, but captures them instead", () => { | ||
const serviceA = { | ||
typeDefs: gql` | ||
type Query { | ||
foo: Bar! | ||
} | ||
extend type Bar @key(fields: "id") { | ||
id: ID! @external | ||
thing: String | ||
} | ||
`, | ||
name: 'serviceA', | ||
}; | ||
let compositionResult: CompositionResult; | ||
expect( | ||
() => (compositionResult = composeAndValidate([serviceA])), | ||
).not.toThrow(); | ||
assertCompositionFailure(compositionResult); | ||
const { errors } = compositionResult; | ||
expect(errors).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"code": "MISSING_ERROR", | ||
"message": "Unknown type \\"Bar\\".", | ||
}, | ||
Object { | ||
"code": "EXTENSION_WITH_NO_BASE", | ||
"message": "[serviceA] Bar -> \`Bar\` is an extension type, but \`Bar\` is not defined in any service", | ||
}, | ||
Object { | ||
"code": "MISSING_ERROR", | ||
"message": "Type Query must define one or more fields.", | ||
}, | ||
] | ||
`); | ||
}); | ||
it('treats types with @extends as type extensions', () => { | ||
@@ -400,3 +441,4 @@ const serviceA = { | ||
assertCompositionSuccess(compositionResult); | ||
expect(compositionResult.schema.getType('CatalogItemEnum')).toMatchInlineSnapshot(` | ||
expect(compositionResult.schema.getType('CatalogItemEnum')) | ||
.toMatchInlineSnapshot(` | ||
enum CatalogItemEnum { | ||
@@ -654,6 +696,9 @@ COUCH | ||
const { schema, composedSdl } = compositionResult; | ||
expect((schema.getType('Product') as GraphQLObjectType).getInterfaces()) | ||
.toHaveLength(2); | ||
expect( | ||
(schema.getType('Product') as GraphQLObjectType).getInterfaces(), | ||
).toHaveLength(2); | ||
expect(printSchema(schema)).toContain('type Product implements Named & Node'); | ||
expect(printSchema(schema)).toContain( | ||
'type Product implements Named & Node', | ||
); | ||
expect(composedSdl).toContain('type Product implements Named & Node'); | ||
@@ -660,0 +705,0 @@ }); |
@@ -408,4 +408,9 @@ import { | ||
errors = validateSDL(definitionsDocument, schema, compositionRules); | ||
schema = extendSchema(schema, definitionsDocument, { assumeValidSDL: true }); | ||
try { | ||
schema = extendSchema(schema, definitionsDocument, { | ||
assumeValidSDL: true, | ||
}); | ||
} catch (e) {} | ||
// Extend the schema with the extension definitions (as an AST node) | ||
@@ -419,3 +424,7 @@ const extensionsDocument: DocumentNode = { | ||
schema = extendSchema(schema, extensionsDocument, { assumeValidSDL: true }); | ||
try { | ||
schema = extendSchema(schema, extensionsDocument, { | ||
assumeValidSDL: true, | ||
}); | ||
} catch {} | ||
@@ -519,2 +528,3 @@ // Remove federation directives from the final schema | ||
const field = namedType.getFields()[fieldName]; | ||
if (!field) break; | ||
@@ -521,0 +531,0 @@ const fieldFederationMetadata: FederationField = { |
Sorry, the diff of this file is not supported yet
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
727249
16017