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

Handle aliases in graphql-flow. #68

Merged
merged 2 commits into from
Jul 26, 2024
Merged

Handle aliases in graphql-flow. #68

merged 2 commits into from
Jul 26, 2024

Conversation

jeresig
Copy link
Member

@jeresig jeresig commented Jul 26, 2024

Summary:

This adds a new option to the config for graphql-flow so that you can specify aliases to map to, to help resolve imports. I used the same format as Vite to keep things simple. This will make it so that we can support our ~/-style imports.

In the process I realized a number of things about this repo were broken, so I fixed them:

  • We weren't running tsc, so I fixed that, and then fixed a bunch of TS failures that were hidden.
  • The ESLint config was broken, so I fixed that (and then fixed all the failures that came up).
  • Prettier was broken (still expecting Flow), so I fixed that.
  • VS Code wasn't set up properly, so I fixed that.
  • The Github PR Workflow was broken, still expecting Flow/.js files, so I fixed that.

Hopefully this helps things to run more smoothly!

Issue: FEI-5745

Test plan:

I ran yarn tsc and yarn eslint src/**/*.ts and they both passed.

@jeresig jeresig self-assigned this Jul 26, 2024
@jeresig jeresig requested a review from a team July 26, 2024 18:59
Copy link

changeset-bot bot commented Jul 26, 2024

🦋 Changeset detected

Latest commit: 89cfb22

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@khanacademy/graphql-flow Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

pathWithoutExtension: string,
config: Config,
): string => {
// Process the path so that we can handle aliases.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the new change.

expect(result).toBe("");
});

it("maps aliases to their correct value", () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the test confirming that it works.

generate: GenerateConfig | Array<GenerateConfig>
crawl: CrawlConfig;
generate: GenerateConfig | Array<GenerateConfig>;
alias?: Array<{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the format of the new alias config setting.

Copy link

@kevinb-khan kevinb-khan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Did we only recently run into issues with graphql-flow having troubles traversing ~/ style imports?

Thanks for fixing all of the tooling in this repo. Sorry for missing that during the TypeScript upgrade.

@jeresig
Copy link
Member Author

jeresig commented Jul 26, 2024

@kevinb-khan So it turns out that I hit this during: https://github.com/Khan/webapp/pull/23926 we were hitting issues where we were importing GraphQL fragments across packages using a ~/ prefix. Before this point there hadn't been any cases of this, but once I started using ~/ everywhere this code started to break.

@jeresig jeresig merged commit d872096 into main Jul 26, 2024
1 check passed
@jeresig jeresig deleted the FEI-5745 branch July 26, 2024 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants