Skip to content

Invalid TypeScript code generated for String fields having default value with line breaks #687

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

Closed
AndKiel opened this issue Jun 13, 2024 · 0 comments · Fixed by #690
Closed

Comments

@AndKiel
Copy link

AndKiel commented Jun 13, 2024

The problem (current behaviour)

When graphQL schema includes String fields having default values with line breaks such as:

  someField: String = "Some\nThing"

then the generated TypeScript code will include an invalid line:

    someField: z.string().default("Some
Thing").nullish(),

resulting in the following compilation error:

error TS1002: Unterminated string literal.

Expected behaviour

When generating default values, strings should be sanitized and used exactly as they are in the input schema, resulting in the following code being generated instead:

    someField: z.string().default("Some\nThing").nullish(),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant