piglovesyou / graphql-let

A webpack loader / babel-plugin / babel-plugin-macros / CLI / generated file manager of GraphQL code generator.
Apache License 2.0
454 stars 34 forks source link

allow passing schema plugins #618

Open villesau opened 2 years ago

villesau commented 2 years ago

Enables passing plugins that work in similar manner to typescript and need to be generated in a single file.

Fixes: https://github.com/piglovesyou/graphql-let/issues/617

Let me know if this is something you'd consider merging and I can work on tests etc. I'm not sure if schemaPlugin is a correct term in this case, but that seemed to be already used in the codebase.

piglovesyou commented 2 years ago

Great. Could you make the build pass? My quick search finds this - Error: Unable to find template plugin matching typescript-urql-graphcache

villesau commented 2 years ago

Sure, I'll fix the remaining tests :+1:

villesau commented 2 years ago

@piglovesyou I've now updated the snapshots. is there something needed besides updated snapshots?

I added a mention about the schemaPlugins to the readme. It's a bit funny example since it has both urql and apollo, but I think the idea is the most important idea there.

villesau commented 2 years ago

I would also consider getting rid of this since schemaPlugins allows controlling optional plugins from the outside:

https://github.com/piglovesyou/graphql-let/blob/88e9c52b1a0a8cd828fd3e4f5d7edd09e80a4b1c/src/lib/codegen.ts#L16-L27

and possibly the default typescript plugin since there's a risk for misconfiguration and having the typescript plugin twice. But those are breaking changes so it does not probably make sense to do such changes in this PR.

piglovesyou commented 2 years ago

Sounds so makes sense. Let's remove OPTIONAL_SCHEMA_PLUGINS (finally!) and ask users to specify typescript-resolvers explicitly. I don't take much time on this project lately, to be honest, so this would be the chance. Or you can leave it if you prefer, it's up to you. In both cases, I'll bump the minor version.

villesau commented 2 years ago

Got rid of OPTIONAL_SCHEMA_PLUGINS and the related logic in the last commit.