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

allow passing schema plugins #618

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

villesau
Copy link

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

Fixes: #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
Copy link
Owner

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

@villesau
Copy link
Author

Sure, I'll fix the remaining tests 👍

@villesau villesau force-pushed the enable-defining-schema-plugins branch from 7c20948 to 330eb82 Compare February 15, 2022 21:28
@villesau villesau force-pushed the enable-defining-schema-plugins branch from 330eb82 to 6a85e0b Compare February 15, 2022 21:42
@villesau
Copy link
Author

villesau commented Feb 15, 2022

@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 villesau force-pushed the enable-defining-schema-plugins branch from af67746 to 88e9c52 Compare February 15, 2022 22:02
@villesau
Copy link
Author

villesau commented Feb 15, 2022

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

const OPTIONAL_SCHEMA_PLUGINS = ['typescript-resolvers'];
function getOptionalSchemaPlugins() {
const plugins: string[] = [];
for (const c of OPTIONAL_SCHEMA_PLUGINS) {
try {
require(`@graphql-codegen/${c}`);
plugins.push(c);
// eslint-disable-next-line no-empty
} catch (e) {}
}
return plugins;
}

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
Copy link
Owner

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
Copy link
Author

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

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.

Not compatible with typescript-urql-graphcache
2 participants