@apollo/federation-internals
Advanced tools
Comparing version 2.1.3 to 2.1.4
# CHANGELOG for `@apollo/federation-internals` | ||
## vNext | ||
## 2.1.4 | ||
- Ensures supergraph `@defer`/`@stream` definitions of supergraph are not included in the API schema [PR #2212](https://github.com/apollographql/federation/pull/2212). | ||
- Fix validation of variable on input field not taking default into account [PR #2176](https://github.com/apollographql/federation/pull/2176). | ||
## 2.1.0 | ||
@@ -4,0 +12,0 @@ |
@@ -10,3 +10,3 @@ "use strict"; | ||
When Apollo Gateway attempts to **compose** the schemas provided by your [subgraphs](./subgraphs/) into a **supergraph schema**, it confirms that: | ||
When Apollo Gateway attempts to **compose** the schemas provided by your [subgraphs](./building-supergraphs/subgraphs-overview/) into a **supergraph schema**, it confirms that: | ||
@@ -13,0 +13,0 @@ * The subgraphs are valid |
@@ -93,4 +93,4 @@ "use strict"; | ||
const v2 = b[key]; | ||
if (v2 === undefined) { | ||
return v1 === undefined && b.hasOwnProperty(key); | ||
if (v2 === undefined && !keys2.includes(key)) { | ||
return false; | ||
} | ||
@@ -394,3 +394,3 @@ if (!valueEquals(v1, v2)) { | ||
valueKeys.delete(field.name); | ||
return isValidValueApplication(value[field.name], field.type, undefined, variableDefinitions); | ||
return isValidValueApplication(value[field.name], field.type, field.defaultValue, variableDefinitions); | ||
}); | ||
@@ -397,0 +397,0 @@ const hasUnexpectedField = valueKeys.size !== 0; |
{ | ||
"name": "@apollo/federation-internals", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"description": "Apollo Federation internal utilities", | ||
@@ -35,3 +35,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "4b075b9fbe3629e09167b280b0005457ad0f593d" | ||
"gitHead": "413ef7911df24c26a1150157e42539f6d4b710df" | ||
} |
@@ -796,53 +796,99 @@ import { | ||
test('correctly convert to a graphQL-js schema', () => { | ||
const sdl = ` | ||
schema { | ||
query: MyQuery | ||
} | ||
describe('Conversion to graphQL-js schema', () => { | ||
test('works on simple schema', () => { | ||
const sdl = ` | ||
schema { | ||
query: MyQuery | ||
} | ||
directive @foo on FIELD | ||
directive @foo on FIELD | ||
type A { | ||
f1(x: Int): String | ||
f2: String | ||
} | ||
type A { | ||
f1(x: Int): String | ||
f2: String | ||
} | ||
type MyQuery { | ||
a: A | ||
b: Int | ||
} | ||
`; | ||
const schema = parseSchema(sdl); | ||
type MyQuery { | ||
a: A | ||
b: Int | ||
} | ||
`; | ||
const schema = parseSchema(sdl); | ||
const graphqQLSchema = schema.toGraphQLJSSchema(); | ||
expect(printGraphQLjsSchema(graphqQLSchema)).toMatchString(sdl); | ||
}); | ||
const graphqQLSchema = schema.toGraphQLJSSchema(); | ||
expect(printGraphQLjsSchema(graphqQLSchema)).toMatchString(sdl); | ||
}); | ||
test('Conversion to graphQL-js schema can optionally include @defer and/or @streams definition(s)', () => { | ||
const sdl = ` | ||
type Query { | ||
x: Int | ||
} | ||
`; | ||
const schema = parseSchema(sdl); | ||
test('can optionally add @defer and/or @streams definition(s)', () => { | ||
const sdl = ` | ||
type Query { | ||
x: Int | ||
} | ||
`; | ||
const schema = parseSchema(sdl); | ||
expect(printGraphQLjsSchema(schema.toGraphQLJSSchema({ includeDefer: true }))).toMatchString(` | ||
directive @defer(label: String, if: Boolean! = true) on FRAGMENT_SPREAD | INLINE_FRAGMENT | ||
expect(printGraphQLjsSchema(schema.toGraphQLJSSchema({ includeDefer: true }))).toMatchString(` | ||
directive @defer(label: String, if: Boolean! = true) on FRAGMENT_SPREAD | INLINE_FRAGMENT | ||
type Query { | ||
x: Int | ||
} | ||
`); | ||
type Query { | ||
x: Int | ||
} | ||
`); | ||
expect(printGraphQLjsSchema(schema.toGraphQLJSSchema({ includeDefer: true, includeStream: true }))).toMatchString(` | ||
directive @defer(label: String, if: Boolean! = true) on FRAGMENT_SPREAD | INLINE_FRAGMENT | ||
expect(printGraphQLjsSchema(schema.toGraphQLJSSchema({ includeDefer: true, includeStream: true }))).toMatchString(` | ||
directive @defer(label: String, if: Boolean! = true) on FRAGMENT_SPREAD | INLINE_FRAGMENT | ||
directive @stream(label: String, initialCount: Int = 0, if: Boolean! = true) on FIELD | ||
directive @stream(label: String, initialCount: Int = 0, if: Boolean! = true) on FIELD | ||
type Query { | ||
x: Int | ||
} | ||
`); | ||
type Query { | ||
x: Int | ||
} | ||
`); | ||
}); | ||
test('adding @defer and/or @streams definition(s) works properly for API schema of supergraphs with their own @defer definition', () => { | ||
// Note that this test doesn't use a valid supergraph schema, but that doesn't really matter in this test. All that matter | ||
// is that taking `toAPISchema()` followed by `toGraphQLJSSchema(config)` works properly when the original schema already has | ||
// a `@defer` definition. | ||
const sdl = ` | ||
directive @defer(label: String, if: Boolean! = true) on FRAGMENT_SPREAD | INLINE_FRAGMENT | ||
directive @stream(label: String, initialCount: Int = 0, if: Boolean! = true) on FIELD | ||
type Query { | ||
x: Int | ||
} | ||
`; | ||
// Note that with API schema, we want the @defer/@stream definitions from the original schema to essentially be ignored. | ||
// So whether or not the @defer/@stream definition ends up in the output of `toGraphQLJSSchema` (of that API schema) should | ||
// solely depend on the config provided to that method. | ||
const apiSchema = parseSchema(sdl).toAPISchema(); | ||
expect(printGraphQLjsSchema(apiSchema.toGraphQLJSSchema())).toMatchString(` | ||
type Query { | ||
x: Int | ||
} | ||
`); | ||
expect(printGraphQLjsSchema(apiSchema.toGraphQLJSSchema({ includeDefer: true }))).toMatchString(` | ||
directive @defer(label: String, if: Boolean! = true) on FRAGMENT_SPREAD | INLINE_FRAGMENT | ||
type Query { | ||
x: Int | ||
} | ||
`); | ||
expect(printGraphQLjsSchema(apiSchema.toGraphQLJSSchema({ includeDefer: true, includeStream: true }))).toMatchString(` | ||
directive @defer(label: String, if: Boolean! = true) on FRAGMENT_SPREAD | INLINE_FRAGMENT | ||
directive @stream(label: String, initialCount: Int = 0, if: Boolean! = true) on FIELD | ||
type Query { | ||
x: Int | ||
} | ||
`); | ||
}); | ||
}); | ||
test('retrieving elements by coordinate', () => { | ||
@@ -849,0 +895,0 @@ const sdl = ` |
@@ -394,2 +394,21 @@ import { | ||
}); | ||
test('allows nullable variable for non-nullable input field with default', () => { | ||
const schema = parseSchema(` | ||
input I { | ||
x: Int! = 42 | ||
} | ||
type Query { | ||
f(i: I): Int | ||
} | ||
`); | ||
// Just testing that this parse correctly and does not throw an exception. | ||
parseOperation(schema, ` | ||
query test($x: Int) { | ||
f(i: { x: $x }) | ||
} | ||
`); | ||
}); | ||
}); | ||
@@ -396,0 +415,0 @@ |
@@ -9,2 +9,3 @@ import { | ||
import { printSchema } from '../print'; | ||
import { valueEquals } from '../values'; | ||
@@ -170,3 +171,3 @@ function parseSchema(schema: string): Schema { | ||
// enum values internally (though this might have backward compatbility constraints), but in the meantime, | ||
// it's unlikely to trip users too much. | ||
// it's unlikely to trip users too much. | ||
expect(buildForErrors(doc)).toStrictEqual([[ | ||
@@ -383,1 +384,10 @@ 'INVALID_GRAPHQL', | ||
}); | ||
describe('objectEquals tests', () => { | ||
it('simple object equality tests', () => { | ||
expect(valueEquals({ foo: 'foo' }, { foo: 'foo'})).toBe(true); | ||
expect(valueEquals({ foo: 'foo', bar: undefined }, { foo: 'foo', bar: undefined})).toBe(true); | ||
expect(valueEquals({ foo: 'foo' }, { foo: 'foo', bar: undefined})).toBe(false); | ||
expect(valueEquals({ foo: 'foo', bar: undefined }, { foo: 'foo' })).toBe(false); | ||
}); | ||
}); |
@@ -9,3 +9,3 @@ import { assert } from './utils'; | ||
When Apollo Gateway attempts to **compose** the schemas provided by your [subgraphs](./subgraphs/) into a **supergraph schema**, it confirms that: | ||
When Apollo Gateway attempts to **compose** the schemas provided by your [subgraphs](./building-supergraphs/subgraphs-overview/) into a **supergraph schema**, it confirms that: | ||
@@ -12,0 +12,0 @@ * The subgraphs are valid |
@@ -164,4 +164,4 @@ import { | ||
// in args2. | ||
if (v2 === undefined) { | ||
return v1 === undefined && b.hasOwnProperty(key); | ||
if (v2 === undefined && !keys2.includes(key)) { | ||
return false; | ||
} | ||
@@ -529,3 +529,3 @@ if (!valueEquals(v1, v2)) { | ||
valueKeys.delete(field.name); | ||
return isValidValueApplication(value[field.name], field.type!, undefined, variableDefinitions) | ||
return isValidValueApplication(value[field.name], field.type!, field.defaultValue, variableDefinitions) | ||
}); | ||
@@ -748,2 +748,1 @@ const hasUnexpectedField = valueKeys.size !== 0 | ||
} | ||
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
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
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
1961696
33037