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

Union type is always generated, even if withObjectType is false #252

Closed
tobiasdiez opened this issue Nov 26, 2022 · 8 comments · Fixed by #280
Closed

Union type is always generated, even if withObjectType is false #252

tobiasdiez opened this issue Nov 26, 2022 · 8 comments · Fixed by #280

Comments

@tobiasdiez
Copy link

If you have a schema

        type Square {
          size: Int
        }
        type Circle {
          radius: Int
        }
        union Shape = Circle | Square

then (with the default withObjectType = false) the generated code contains

export function ShapeSchema() {
    return z.union([CircleSchema(), SquareSchema()])
}

but the referenced type schemas CircleSchema and SquareSchema don't exist. Thus, the union schema should also not be generated if withObjectType is false.

@sschneider-ihre-pvs
Copy link
Contributor

have a similar problem with just using union as type alias

@sschneider-ihre-pvs
Copy link
Contributor

@Code-Hex also the uniontypedefinition seems to be missing in the latest version?!

@sschneider-ihre-pvs
Copy link
Contributor

image

@Code-Hex
Copy link
Owner

@tobiasdiez Thanks I will fix it!

@sschneider-ihre-pvs I cannot read your JavaScript

@sschneider-ihre-pvs
Copy link
Contributor

@tobiasdiez Thanks I will fix it!

@sschneider-ihre-pvs I cannot read your JavaScript

that is the published js from the npm package

@anhdd-kuro
Copy link
Contributor

anhdd-kuro commented Dec 22, 2022

@alisabzevari
sorry for mention , thought you can find the problem in #237

@Code-Hex
Copy link
Owner

@tobiasdiez @anhdd-kuro I just published the latest version (v0.7.1) which is contained this fix.

I'm sorry too late.

https://github.com/Code-Hex/graphql-codegen-typescript-validation-schema/releases/tag/v0.7.1

@tobiasdiez
Copy link
Author

I can confirm that it is working now. Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants