-
-
Notifications
You must be signed in to change notification settings - Fork 181
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
Support GraphQL Config in graphql-codegen plugin #645
Support GraphQL Config in graphql-codegen plugin #645
Conversation
Thanks for the PR, @taro-28! I'm wondering, what is the reason to extend the Their docs show the |
Thanks for your comment! I haven't fully understood how to add the plugin yet, but would it be okay if I tried it while looking at the existing code? I am thinking of the following flow:
|
In case you've missed it, here's a guide to create the plugin including boilerplate generation: https://knip.dev/guides/writing-a-plugin That said, of course you can also copy-paste an existing similar plugin.
Do you mean that the config file is useful without the dependency/ies being installed? If so, do you maybe have an explanation or link about this? |
Thank you very much. I will try with reference to those.
Libraries like So for users (not library developers), I think installing graphql-config is necessary only when they want to use types in a TypeScript configuration file like |
Thanks for clarifying, now I see why you've extended the existing plugin. Having one plugin makes the implementation more complex, but I guess it's the way to go :)
How about using Feel free to create multiple fixture folders to test the various use cases. |
I see. You're right.
Thanks, all right :) |
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.
I have added graphql-config
to enablers
and added test cases.
Please review them at your convenience.
The CI is failing on integration with InvokeAI
, and it seems to be caused by recent changes in invoke-ai/InvokeAI
. How should I address this issue?
When I clone the repository and run the same commands as the CI, I encounter an error with knip-bun --production --fix --no-exit-code
.
git clone https://github.com/invoke-ai/InvokeAI.git
cd InvokeAI/invokeai/frontend/web
pnpm install
pnpm exec knip-bun
# Error occurs
pnpm exec knip-bun --production --fix --no-exit-code
packages/knip/src/types/plugins.ts
Outdated
@@ -38,7 +38,7 @@ export type Resolve = (options: PluginOptions) => Promise<string[]> | string[]; | |||
export interface Plugin { | |||
title: string; | |||
enablers: IgnorePatterns | string; | |||
packageJsonPath?: string; | |||
packageJsonPath?: string | string[]; |
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.
Add string[]
for const packageJsonPath = ['codegen', 'graphql'];
.
https://github.com/webpro/knip/pull/645/files#diff-ddb93d5a83e62c0a323ac509f0a99c1cd54051e8a6a35ff4168e4af886d2a615
packages/knip/src/WorkspaceWorker.ts
Outdated
get( | ||
this.manifest, | ||
(Array.isArray(packageJsonPath) | ||
? packageJsonPath.find(path => get(this.manifest, path)) | ||
: packageJsonPath) ?? pluginName | ||
) |
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.
I would appreciate it, if there is a simpler way to do this…!
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.
Just an idea, maybe it would be slightly simpler if we would accept a function instead of an array, something like this:
typeof packageJsonPath === 'function'
? packageJsonPath(this.manifest)
: (get(this.manifest, plugin.packageJsonPath) ?? pluginName)
Not much better, but at least any (additional) complexity is moved to the plugin.
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.
at least any (additional) complexity is moved to the plugin.
Certainly..., thank you...!
Fixed!
58f13a7
Yeah this sometimes happens. I've "fixed" it in main, so if you rebase the lights should go green again. |
Pinging @beaussan, as you're the original author of the plugin. Any chance there's public repos using this plugin you could point us to so we can verify there are no regressions? |
… installed graphql-config
…codegen-graphql-config.test2.ts
…lugins/graphql-codegen-graphql-config2
8310bf1
to
29382e0
Compare
Thanks, I rebased and it fixed it. |
Excellent stuff, @taro-28! Going to merge it now and it'll be part of a bigger release, expected later this week. |
@webpro |
I've check everything and it looks great to me! |
Thank you so much, Nicolas! Didn't want to give you any more work so asked for repos, but this is even better! 🙏 Should go out later this week. |
🚀 This pull request is included in v5.17.0-canary.0. See Release 5.17.0-canary.0 for release notes. Using Knip in a commercial project? Please consider sponsoring me. |
Added support for GraphQL Config in graphql-codegen plugin config file.
https://the-guild.dev/graphql/config