Code-Hex / graphql-codegen-typescript-validation-schema

GraphQL Code Generator plugin to generate form validation schema from your GraphQL schema
MIT License
315 stars 42 forks source link

Only enums are generated #880

Open Sam-Kruglov opened 2 days ago

Sam-Kruglov commented 2 days ago

I only see these imports:

import { z } from 'zod'
import { AccountType, ErrorClassification, PaymentStatus } from './graphql'

But I don't see anything else, like this for example:

export type SubmitPaymentMutationVariables = Exact<{
  accountId: Scalars['ID']['input'];
  amount: Scalars['String']['input'];
}>;

Config:

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

const config: CodegenConfig = {
  schema: [
    {
      [process.env.NEXT_PUBLIC_GRAPHQL_URL_SCHEMA as string]: {
        // @ts-ignore https://github.com/dotansimha/graphql-code-generator/issues/9309
        handleAsSDL: true,
        method: 'GET'
      }
    }
  ],
  documents: ['data/**/*.ts'],
  ignoreNoDocuments: true,
  generates: {
    './data/graphql/generated/': {
      preset: 'client',
      config: {
        strictScalars: true,
        scalars: {
          ID: 'string'
        }
      }
    },
    './data/graphql/generated/graphql.zod.ts': {
      plugins: ['typescript-validation-schema'],
      config: {
        importFrom: './graphql',
        schema: 'zod',
        strictScalars: true,
        scalars: {
          ID: 'string'
        }
      }
    }
  }
}

export default config
Sam-Kruglov commented 2 days ago

I did consider the workaround, even slightly modifying to be exactly like in #303 but it's the same. Also tried yup but also the same.