-
Notifications
You must be signed in to change notification settings - Fork 276
Fix repeatable custom directives #2136
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
32983e9
Fix repeatable custom directives
clenfest 34c8915
adding changelog entry
clenfest 1d2165c
remove debug code
clenfest e4e8e97
Updates based on code review comments
clenfest 1dbbc1d
put mergeAllAppliedDirectives() call in the right spot
clenfest a0b1199
reset array when done
clenfest a14cc08
rename function
clenfest 6e9eeeb
Merge branch 'main' into clenfest/2134
clenfest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { | ||
| asFed2SubgraphDocument, | ||
| buildSchema, | ||
| extractSubgraphsFromSupergraph, | ||
| Schema, | ||
| ServiceDefinition, | ||
| Subgraphs | ||
| } from '@apollo/federation-internals'; | ||
| import { CompositionResult, composeServices, CompositionSuccess } from '../compose'; | ||
|
|
||
| export function assertCompositionSuccess(r: CompositionResult): asserts r is CompositionSuccess { | ||
| if (r.errors) { | ||
| throw new Error(`Expected composition to succeed but got errors:\n${r.errors.join('\n\n')}`); | ||
| } | ||
| } | ||
|
|
||
| export function errors(r: CompositionResult): [string, string][] { | ||
| return r.errors?.map(e => [e.extensions.code as string, e.message]) ?? []; | ||
| } | ||
|
|
||
| // Returns [the supergraph schema, its api schema, the extracted subgraphs] | ||
| export function schemas(result: CompositionSuccess): [Schema, Schema, Subgraphs] { | ||
| // Note that we could user `result.schema`, but reparsing to ensure we don't lose anything with printing/parsing. | ||
| const schema = buildSchema(result.supergraphSdl); | ||
| expect(schema.isCoreSchema()).toBeTruthy(); | ||
| return [schema, schema.toAPISchema(), extractSubgraphsFromSupergraph(schema)]; | ||
| } | ||
|
|
||
| // Note that tests for composition involving fed1 subgraph are in `composeFed1Subgraphs.test.ts` so all the test of this | ||
| // file are on fed2 subgraphs, but to avoid needing to add the proper `@link(...)` everytime, we inject it here automatically. | ||
| export function composeAsFed2Subgraphs(services: ServiceDefinition[]): CompositionResult { | ||
| return composeServices(services.map((s) => asFed2Service(s))); | ||
| } | ||
|
|
||
| export function asFed2Service(service: ServiceDefinition): ServiceDefinition { | ||
| return { | ||
| ...service, | ||
| typeDefs: asFed2SubgraphDocument(service.typeDefs) | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,7 +147,7 @@ describe('lifecycle hooks', () => { | |
| // the supergraph (even just formatting differences), this ID will change | ||
| // and this test will have to updated. | ||
| expect(secondCall[0]!.compositionId).toEqual( | ||
| 'cc95112b64179c4e549de788b051f44010a02877f568649a42caeeee6a135601', | ||
| 'a7e83d2e958dc8e0f08326443113802c900a4d977a26df6cfda599f138d9bb2f', | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to reviewers: This is just a reordering of applied directives in the SDL (see the diff in the .snap file for a similar case). |
||
| ); | ||
| // second call should have previous info in the second arg | ||
| expect(secondCall[1]!.compositionId).toEqual(expectedFirstId); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to reviewers: I noticed that
compose.test.tstests were getting run multiple times because the helper functions were being imported from other files, so I split those out into a separate file.