-
Notifications
You must be signed in to change notification settings - Fork 463
Avoid re-introspecting within local graphql context and exclude client-only directives.
#614
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 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1365e2d
Revert "Fall back to other methods of schema loading when one fails (…
abernix 9ccaf18
Rename `execute` to `linkExecute` to disambiguate from `graphql`'s `e…
abernix cbf6fb0
Don't `export` unused `fromFile` method.
abernix 283626b
Switch to a more natural `async`/`await` workflow.
abernix d579adb
fix introspection result loading from local files by replacing source…
e1aae5e
Reduce the scope of the `try` / `catch` within `fromFile`.
abernix 88a248c
remove @client and @connection directives and fields from queries by …
c305481
Correct signature of `getCommonManifestTasks` to accept object with `…
abernix d31f9a8
Rename `buildIntrospectionSche...` to `buildIntrospectionSchemaFromSDL`.
abernix 72bf154
Properly surface GraphQL errors in introspection error message.
abernix 9be573a
Raise an error first if `errors` are present and second if `data` is …
abernix 8e144a1
Switch `introspectionResult` to the more accurate `introspectionSchema`.
abernix 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
100 changes: 100 additions & 0 deletions
100
packages/apollo-codegen-core/src/utilities/__tests__/graphql.test.ts
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,100 @@ | ||
| import { parse, print } from "graphql"; | ||
| import { | ||
| withTypenameFieldAddedWhereNeeded, | ||
| removeConnectionDirectives, | ||
| removeClientDirectives | ||
| } from "../graphql"; | ||
|
|
||
| describe("typename additions", () => { | ||
| it("adds typenames to selectionSets", () => { | ||
| const original = parse(` | ||
| query GetUser { | ||
| me { | ||
| firstName | ||
| friends { | ||
| firstName | ||
| } | ||
| } | ||
| } | ||
| `); | ||
|
|
||
| const modified = print( | ||
| parse(` | ||
| query GetUser { | ||
| me { | ||
| __typename | ||
| firstName | ||
| friends { | ||
| __typename | ||
| firstName | ||
| } | ||
| } | ||
| } | ||
| `) | ||
| ); | ||
|
|
||
| const newQuery = withTypenameFieldAddedWhereNeeded(original); | ||
| expect(print(newQuery)).toEqual(modified); | ||
| }); | ||
| }); | ||
|
|
||
| describe("client removals", () => { | ||
| it("removes the @connection directive", () => { | ||
| const original = parse(` | ||
| query GetUser { | ||
| list @connection(key: "Value") | ||
| } | ||
| `); | ||
|
|
||
| const modified = print( | ||
| parse(` | ||
| query GetUser { | ||
| list | ||
| } | ||
| `) | ||
| ); | ||
|
|
||
| const newQuery = removeConnectionDirectives(original); | ||
| expect(print(newQuery)).toEqual(modified); | ||
| }); | ||
| it("removes @client id from a mixed query", () => { | ||
| const original = parse(` | ||
| query GetUser { | ||
| list @client | ||
| remote { | ||
| id | ||
| virtual @client | ||
| virtualSelectionSet @client @export(as: "id") { | ||
| name | ||
| } | ||
| } | ||
| } | ||
| `); | ||
|
|
||
| const modified = print( | ||
| parse(` | ||
| query GetUser { | ||
| remote { | ||
| id | ||
| } | ||
| } | ||
| `) | ||
| ); | ||
|
|
||
| const newQuery = removeClientDirectives(original); | ||
| expect(print(newQuery)).toEqual(modified); | ||
| }); | ||
| it("returns and empty string when removing all fields", () => { | ||
| const original = parse(` | ||
| query GetUser { | ||
| list @client | ||
| local @client { | ||
| id | ||
| } | ||
| } | ||
| `); | ||
|
|
||
| const newQuery = removeClientDirectives(original); | ||
| expect(print(newQuery).trim()).toBeFalsy(); | ||
| }); | ||
| }); |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.