Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core schema support and Typescript query planner redux #622

Merged
merged 51 commits into from
Mar 31, 2021
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1322e44
Initial copy/paste for simpler diffing against
trevor-scheer Mar 18, 2021
0aa65fb
Implement core spec
trevor-scheer Mar 18, 2021
f1e0a8a
Initial impl of join spec
trevor-scheer Mar 18, 2021
f9f3784
Implement http directive for join__Graph enum
trevor-scheer Mar 19, 2021
06c42ad
Re-introduce last used TypeScript query planner code
martijnwalraven Mar 19, 2021
9a1e715
Use Federation metadata from composed schema
martijnwalraven Mar 19, 2021
9dab51d
Copy feature tests from Rust query planner to `@apollo/query-planner`…
martijnwalraven Mar 19, 2021
9af5533
Fix discrepancy in schema used for feature test
martijnwalraven Mar 19, 2021
ac540d2
Add `isNotNullOrUndefined` and remove dependency on `apollo-env`
martijnwalraven Mar 19, 2021
d2ef7c6
Change `getBaseService` and `getOwningService` to return `undefined` …
martijnwalraven Mar 19, 2021
4911364
Treat abstract types as value types to replicate type explosion fix
martijnwalraven Mar 19, 2021
5b8dc42
Make test pass by removing code that changes field ordering
martijnwalraven Mar 19, 2021
439fad2
Disable test for propagation of directives on inline fragments
martijnwalraven Mar 19, 2021
6cb2023
Update ordering of fragments in snapshots for autofragmentization tests
martijnwalraven Mar 19, 2021
b9f3a7c
Merge branch 'trevor/print-core-schema' into typescript-redux
martijnwalraven Mar 21, 2021
a09e433
Print valid core schema and change `@http` to `@join__endpoint`
martijnwalraven Mar 21, 2021
cbbf8cb
Adapt query planner to core schema input
martijnwalraven Mar 21, 2021
081c59e
Skip tests that fail because of value type handling in composition
martijnwalraven Mar 21, 2021
1e324f2
Print valid core schema and change `@http` to `@join__endpoint`
martijnwalraven Mar 21, 2021
eadfe94
Remove copy/pasta extension code from both composed and core printers
trevor-scheer Mar 22, 2021
2313d5a
Reintroduce fieldSet parseability test
trevor-scheer Mar 22, 2021
37773db
Cleanup test case
trevor-scheer Mar 22, 2021
166bce7
Merge branch 'trevor/print-core-schema' into typescript-redux
martijnwalraven Mar 23, 2021
bf79bec
Filter out core and join elements in `buildComposedSchema`
martijnwalraven Mar 24, 2021
70dce5c
Make the `graph` argument in `join__owner` and `join__type` non-nullable
martijnwalraven Mar 24, 2021
80e4431
Make `@provides` on value types work by printing `@join__field` witho…
martijnwalraven Mar 24, 2021
63658b8
Avoid printing `@join__field` for what should be value types
martijnwalraven Mar 24, 2021
0365de6
Change `@join__endpoint(serviceName:url:)` to `@join__graph(name:url:)`
martijnwalraven Mar 24, 2021
0b133e5
Uniquify and sanitize enum values in the join__Graph enum
trevor-scheer Mar 24, 2021
1b2af2d
Always invoke `GraphQLNonNull` as a constructor
martijnwalraven Mar 25, 2021
31a7ba6
Propagate directives on inline fragments to subqueries
martijnwalraven Mar 25, 2021
88f8c09
Escape string literals when printing core schema
martijnwalraven Mar 28, 2021
3350d86
Fix bug in the type explosion workaround code
martijnwalraven Mar 29, 2021
9cb48f1
Rename leftover endpointDirectiveArgs to graphDirectiveArgs
martijnwalraven Mar 29, 2021
4b7df18
Add hard coded feature and version checking for core schema
martijnwalraven Mar 29, 2021
3f860e3
harmonizer: Update to use `coreSchema` rather than `composedSdl`.
abernix Mar 30, 2021
da7a186
chore(harmonizer): Bump minor version to reflect new output
abernix Mar 30, 2021
25b5453
Make context a required arg everywhere, pass to printInterface
trevor-scheer Mar 30, 2021
973db23
Print @join__type directives on interface types
trevor-scheer Mar 30, 2021
22e6e77
Remove CSDL
trevor-scheer Mar 30, 2021
eb6676b
fix(gateway): Address typings issue for getDefaultFetcher (#585)
trevor-scheer Mar 18, 2021
6906a8c
Change lib.apollo.dev to specs.apollo.dev
martijnwalraven Mar 31, 2021
247fb10
Remove unnecessary assignment from `MultiMap`
martijnwalraven Mar 31, 2021
bc31b88
Only filter out directives with the unprefixed feature name
martijnwalraven Mar 31, 2021
19ae2f6
Address typos and enforce specifying assertion messages
martijnwalraven Mar 31, 2021
36cdac4
Avoid unnecessary check for undefined
martijnwalraven Mar 31, 2021
5b30ba8
Rename Endpoint -> Graph and serviceName -> graphName
martijnwalraven Mar 31, 2021
6abb7d4
Merge branch 'release-0.26.0' into typescript-redux
trevor-scheer Mar 31, 2021
466c6e1
Update the thing that TS didn't catch for me :sadface:
trevor-scheer Mar 31, 2021
f9e4cf7
(optionally) REVERT ME: cachebuster
trevor-scheer Mar 31, 2021
9db6aa9
Update changelogs
trevor-scheer Mar 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Avoid printing @join__field for what should be value types
We should change the way we detect value types. If a type is defined in only one service, we currently don't consider it a value type even if it doesn't specify any keys.

That resulted in us printing `@join__field`, with the name of the single service that defined the type, even though we didn't add a corresponding `join__type` to the parent type (because that relies on there being keys defined). That is invalid according to the join spec, and also broke the current workaround for avoiding type explosion on value types (which we should replace, but are leaving in for now to first replicate the existing behavior).
  • Loading branch information
martijnwalraven committed Mar 24, 2021
commit 63658b82ed2fb51ffacfe3ae0c6aff350e1d83e6
60 changes: 30 additions & 30 deletions federation-js/src/service/__tests__/printCoreSchema.test.ts
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ describe('printCoreSchema', () => {
union AccountType = PasswordAccount | SMSAccount

type Amazon {
referrer: String @join__field(graph: PRODUCT)
referrer: String
}

union Body = Image | Text
@@ -116,16 +116,16 @@ describe('printCoreSchema', () => {
}

type Ikea {
asile: Int @join__field(graph: PRODUCT)
asile: Int
}

type Image {
name: String! @join__field(graph: DOCUMENTS)
attributes: ImageAttributes! @join__field(graph: DOCUMENTS)
name: String!
attributes: ImageAttributes!
}

type ImageAttributes {
url: String! @join__field(graph: DOCUMENTS)
url: String!
}

scalar join__FieldSet
@@ -164,8 +164,8 @@ describe('printCoreSchema', () => {
}

type Name {
first: String @join__field(graph: ACCOUNTS)
last: String @join__field(graph: ACCOUNTS)
first: String
last: String
}

type PasswordAccount
@@ -176,27 +176,27 @@ describe('printCoreSchema', () => {
}

interface Product {
upc: String! @join__field(graph: PRODUCT)
sku: String! @join__field(graph: PRODUCT)
name: String @join__field(graph: PRODUCT)
price: String @join__field(graph: PRODUCT)
details: ProductDetails @join__field(graph: PRODUCT)
inStock: Boolean @join__field(graph: PRODUCT)
reviews: [Review] @join__field(graph: PRODUCT)
upc: String!
sku: String!
name: String
price: String
details: ProductDetails
inStock: Boolean
reviews: [Review]
}

interface ProductDetails {
country: String @join__field(graph: PRODUCT)
country: String
}

type ProductDetailsBook implements ProductDetails {
country: String @join__field(graph: PRODUCT)
pages: Int @join__field(graph: PRODUCT)
country: String
pages: Int
}

type ProductDetailsFurniture implements ProductDetails {
country: String @join__field(graph: PRODUCT)
color: String @join__field(graph: PRODUCT)
country: String
color: String
}

type Query {
@@ -232,13 +232,13 @@ describe('printCoreSchema', () => {
}

type Text {
name: String! @join__field(graph: DOCUMENTS)
attributes: TextAttributes! @join__field(graph: DOCUMENTS)
name: String!
attributes: TextAttributes!
}

type TextAttributes {
bold: Boolean @join__field(graph: DOCUMENTS)
text: String @join__field(graph: DOCUMENTS)
bold: Boolean
text: String
}

union Thing = Car | Ikea
@@ -271,9 +271,9 @@ describe('printCoreSchema', () => {
}

type UserMetadata {
name: String @join__field(graph: ACCOUNTS)
address: String @join__field(graph: ACCOUNTS)
description: String @join__field(graph: ACCOUNTS)
name: String
address: String
description: String
}

type Van implements Vehicle
@@ -288,10 +288,10 @@ describe('printCoreSchema', () => {
}

interface Vehicle {
id: String! @join__field(graph: PRODUCT)
description: String @join__field(graph: PRODUCT)
price: String @join__field(graph: PRODUCT)
retailPrice: String @join__field(graph: PRODUCT)
id: String!
description: String
price: String
retailPrice: String
}
"
`);
9 changes: 8 additions & 1 deletion federation-js/src/service/printCoreSchema.ts
Original file line number Diff line number Diff line change
@@ -333,8 +333,15 @@ function printJoinFieldDirectives(
let printed = ' @join__field(';
// Fields on the owning service do not have any federation metadata applied
// TODO: maybe make this metadata available? Though I think this is intended and we may depend on that implicity.

if (!field.extensions?.federation) {
if (parentType.extensions?.federation?.serviceName) {
// FIXME: We should change the way we detect value types. If a type is
// defined in only one service, we currently don't consider it a value type
// even if it doesn't specify any keys.
// Because we print `@join__type` directives based on the keys, but only used to
// look at the owning service here, that meant we would print `@join__field`
// without a corresponding `@join__type`, which is invalid according to the spec.
if (parentType.extensions?.federation?.serviceName && parentType.extensions?.federation?.keys) {
return printed + `graph: ${parentType.extensions?.federation.serviceName.toUpperCase()})`;
}
return '';
Original file line number Diff line number Diff line change
@@ -741,7 +741,7 @@ describe('unions', () => {
`);
});

it.skip("doesn't expand interfaces with inline type conditions if all possibilities are fufilled by one service", async () => {
it("doesn't expand interfaces with inline type conditions if all possibilities are fufilled by one service", async () => {
const query = `#graphql
query GetProducts {
topProducts {
60 changes: 30 additions & 30 deletions gateway-js/src/__tests__/loadCsdlFromStorage.test.ts
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ describe('loadCsdlFromStorage', () => {
union AccountType = PasswordAccount | SMSAccount

type Amazon {
referrer: String @join__field(graph: PRODUCT)
referrer: String
}

union Body = Image | Text
@@ -114,16 +114,16 @@ describe('loadCsdlFromStorage', () => {
}

type Ikea {
asile: Int @join__field(graph: PRODUCT)
asile: Int
}

type Image {
name: String! @join__field(graph: DOCUMENTS)
attributes: ImageAttributes! @join__field(graph: DOCUMENTS)
name: String!
attributes: ImageAttributes!
}

type ImageAttributes {
url: String! @join__field(graph: DOCUMENTS)
url: String!
}

scalar join__FieldSet
@@ -162,8 +162,8 @@ describe('loadCsdlFromStorage', () => {
}

type Name {
first: String @join__field(graph: ACCOUNTS)
last: String @join__field(graph: ACCOUNTS)
first: String
last: String
}

type PasswordAccount
@@ -174,27 +174,27 @@ describe('loadCsdlFromStorage', () => {
}

interface Product {
upc: String! @join__field(graph: PRODUCT)
sku: String! @join__field(graph: PRODUCT)
name: String @join__field(graph: PRODUCT)
price: String @join__field(graph: PRODUCT)
details: ProductDetails @join__field(graph: PRODUCT)
inStock: Boolean @join__field(graph: PRODUCT)
reviews: [Review] @join__field(graph: PRODUCT)
upc: String!
sku: String!
name: String
price: String
details: ProductDetails
inStock: Boolean
reviews: [Review]
}

interface ProductDetails {
country: String @join__field(graph: PRODUCT)
country: String
}

type ProductDetailsBook implements ProductDetails {
country: String @join__field(graph: PRODUCT)
pages: Int @join__field(graph: PRODUCT)
country: String
pages: Int
}

type ProductDetailsFurniture implements ProductDetails {
country: String @join__field(graph: PRODUCT)
color: String @join__field(graph: PRODUCT)
country: String
color: String
}

type Query {
@@ -230,13 +230,13 @@ describe('loadCsdlFromStorage', () => {
}

type Text {
name: String! @join__field(graph: DOCUMENTS)
attributes: TextAttributes! @join__field(graph: DOCUMENTS)
name: String!
attributes: TextAttributes!
}

type TextAttributes {
bold: Boolean @join__field(graph: DOCUMENTS)
text: String @join__field(graph: DOCUMENTS)
bold: Boolean
text: String
}

union Thing = Car | Ikea
@@ -269,9 +269,9 @@ describe('loadCsdlFromStorage', () => {
}

type UserMetadata {
name: String @join__field(graph: ACCOUNTS)
address: String @join__field(graph: ACCOUNTS)
description: String @join__field(graph: ACCOUNTS)
name: String
address: String
description: String
}

type Van implements Vehicle
@@ -286,10 +286,10 @@ describe('loadCsdlFromStorage', () => {
}

interface Vehicle {
id: String! @join__field(graph: PRODUCT)
description: String @join__field(graph: PRODUCT)
price: String @join__field(graph: PRODUCT)
retailPrice: String @join__field(graph: PRODUCT)
id: String!
description: String
price: String
retailPrice: String
}
",
"id": "originalId-1234",
Loading