-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
client-preset
does not forward dedupeOperationSuffix
#8576
Comments
client-preset
does not forward dedupeFragments
and dedupeOperationSuffix
client-preset
does not forward dedupeOperationSuffix
There seems to be a bunch of options that aren't being forwarded right now 😞 config:
typesPrefix: I
enumPrefix: I
enumsAsTypes: true
documentVariableSuffix: Doc
fragmentVariableSuffix: Fragment
omitOperationSuffix: true
dedupeFragments: true
exportFragmentSpreadSubTypes: true
nonOptionalTypename: true
flattenGeneratedTypes: false |
This is intentional as the |
@n1ru4l It makes sense that all options should not be allowed, but Additionally, there is some quite odd behavior right now where if you pass |
Why do you need to provide In order to migrate to client preset you can use multiple code generation outputs with local instead of global configuration options for the "old" code. |
@n1ru4l We have a lot of places where we import query result and fragment types, if they end in Fragment/Query/Mutation, the suffix will be duplicated. |
@n1ru4l Maybe |
Should this be reopened? |
I'll share my point of view here, and I hope this answers some of the mystery about adding suffixes in the first place, and also where we are right now.
I do understand that some use cases still use the types directly, but I would like to suggest a different approach. The So you can easily have full control of the type system, and create your own types based on your needs: import { graphql } from './gql';
import { ResultOf } from '';
const myQuery = graphql(`...`);
// Type can be inferred and named based on your preference:
export type MyQueryType = ResultOf<typeof myQuery>; This can also happen on the fly if you prefer: import { myQuery } from './some-file';
const MyComponent = (props: {
data: ResultOf<typeof myQuery>
}) => {
// ...
}; Btw, there are more utils available in |
Is there guidance for my situation? I have an existing repository with ~120 components, each using the pattern:
My operation names include the suffix ( Otherwise it seems like I have to update ~120 components to use the (albeit better) approach. I would much rather be able to migrate them over one at a time. |
Describe the bug
The
client-preset
forwards a very small sub-set of configs to the lower level as can be seen here.This is problematic since I'm not able to set some of the options supported by the the
typescript-operations
plugin.Your Example Website or App
https://github.com/ntungare/graphql-codegen-example
Steps to Reproduce the Bug or Issue
Use the codegen config attached, the effect of the
dedupeOperationSuffix
is not seen.Expected behavior
All configs are respected since the preset is just a combination of the plugin.
I'd like to not use the
gql-tag-operations-preset
but this is blocker for that. And thegql-tag-operations-preset
is supposedly deprecated?Screenshots or Videos
No response
Platform
"graphql": "^16.6.0"
"graphql-tag": "^2.12.6"
"@graphql-codegen/cli": "^2.13.8"
"@graphql-codegen/gql-tag-operations-preset": "^1.7.0"
Codegen Config File
Additional context
Using the above config the
dedupeFragments
is respected but not thededupeOperationSuffix
config.The text was updated successfully, but these errors were encountered: