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

doesn't work with client-preset #303

Closed
erwan-joly opened this issue Feb 12, 2023 · 5 comments
Closed

doesn't work with client-preset #303

erwan-joly opened this issue Feb 12, 2023 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@erwan-joly
Copy link

erwan-joly commented Feb 12, 2023

Hi, it seems like when using the client-preset the configuration is totally ignored.

import { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
    sort: false,
    schema: "file.graphql",
    documents: [
        "src/**/*.gql"
    ],
    ignoreNoDocuments: true,
    generates: {
        './src/graphql/': {
            preset: 'client',
            plugins: [
                "typescript-validation-schema",
            ],
            config: {
                 importFrom: './graphql',
                strictScalars: true,
                schema: 'zod',
            }
        }
    }
}

export default config

this code would result in the validation schema using yup (default configuration) instead of zod

I need an extra generation to get it to use the right configuration

import { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
    sort: false,
    schema: "file.graphql",
    documents: [
        "src/**/*.gql"
    ],
    ignoreNoDocuments: true,
    generates: {
        './src/graphql/validation.ts': {
            plugins: [
                "typescript-validation-schema",
            ],
            config: {
                importFrom: './graphql',
                strictScalars: true,
                schema: 'zod',
            }
        },
        './src/graphql/': {
            preset: 'client',
            plugins: [],
            config: {
            
            }
        }
    }
}

export default config
@Code-Hex
Copy link
Owner

@erwan-joly Thank you for pointing out the compatibility issue with the client-preset. I understand that the configuration is not being applied as expected when using it. Your input is valuable, and I appreciate your effort in sharing the workaround you've found.

To help other users who may encounter the same issue, it would be great if you could create a pull request to update the README with this information. I believe this would be a valuable addition to the documentation.

Thank you once again for your contribution, and I look forward to your continued support.

@Code-Hex Code-Hex added the documentation Improvements or additions to documentation label Apr 18, 2023
@erwan-joly
Copy link
Author

Sure will try to do that as soon as I have some spare time :)

@Code-Hex
Copy link
Owner

Code-Hex commented May 5, 2023

Close by #361

@Code-Hex Code-Hex closed this as completed May 5, 2023
@erwan-joly
Copy link
Author

@Code-Hex is the workaround good enough ? seems a bit dirty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants