graphql-code-generator-community icon indicating copy to clipboard operation
graphql-code-generator-community copied to clipboard

Add persistedDocuments support for other presets or add it to a plugin.

Open negezor opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe.

We have @graphql-codegen/client-preset which has a persistedDocuments config, however I am using @graphql-codegen/near-operation-file-preset and there is no way to calculate the hash here.

Describe the solution you'd like

Implement persistedDocuments for @graphql-codegen/near-operation-file-preset

Describe alternatives you've considered

Implement this as a plugin and use it for all presets at once.

Additional context

I am currently using urql with automatic hash calculation. I found the following plugin graphql-codegen-persisted-query-ids, but it doesn't calculate the hash correctly.

negezor avatar Nov 15 '23 10:11 negezor

@saihaj gentle ping. Is there any chance that this will appear in the near-operation-file-preset? This is the second most popular preset after @graphql-codegen/client-preset which comes by default.

negezor avatar Jul 12 '24 13:07 negezor

I'm very interested in this functionality as well. I've added a PR as a starting point, having Cline / Anthropic AI see if it could figure out how client-preset worked and port the functionality. Hoping someone else knows how to properly test and finish the PR.

Shane32 avatar Nov 22 '24 21:11 Shane32

I wrote a working plugin for client-preset to replace the functionality in near-operation-file-preset. As a plugin, it supports all options that client-preset does, including persisted document support. Does anyone want to volunteer to make it into a PR for this repo? Source code at https://github.com/Shane32/graphql-codegen-near-operation-file-plugin

Shane32 avatar Nov 29 '24 22:11 Shane32