Closed sinisterstumble closed 3 years ago
Just out of curiosity: what was the motivation for exporting these functions?
@louisscruz for a vite plugin. To avoid the need to fork the repository for this:
export const viteGraphQLPlugin = (
options: GraphQLLoaderPluginOptions = {}
): VitePlugin => ({
name: 'graphql',
transform(graphqlString: string, id: string) {
if ((options.filterRegex ?? /\.graphql$/).test(id)) {
return {
code: generateContentsFromGraphqlString(
graphqlString,
options.mapDocumentNode
),
map: null
}
}
return
}
})
@louisscruz unplugin, unified plugin system for vite, rollup, and webpack, is another possible option.
After a lot of internal deliberation over this one, I've decided to allow for these functions to be exposed. Generally, I am not in favor of exposing more than is needed in order to keep future implementation and API changes as simple as possible. But this seems harmless enough. Hopefully this doesn't become some source of regret in the future 😆 .
Merged here https://github.com/luckycatfactory/esbuild-graphql-loader/pull/25 and made available as v3.7.0.
@louisscruz thank you!
export
generateGraphQLString
andgenerateContentsFromGraphqlString