Open ryall opened 3 years ago
+1
Here's another example:
type TypeA {
propA: String
}
type TypeB {
propB: Boolean
}
union TypeAB = TypeA | TypeB
type someRandomType {
typeAB: TypeAB
}
Results in the following typescript code:
...
@TypeGraphQL.ObjectType()
export class TypeA {
__typename?: 'TypeA';
@TypeGraphQL.Field(type => String, { nullable: true })
propA!: Maybe<Scalars['String']>;
};
@TypeGraphQL.ObjectType()
export class TypeB {
__typename?: 'TypeB';
@TypeGraphQL.Field(type => Boolean, { nullable: true })
propB!: Maybe<Scalars['Boolean']>;
};
export type TypeAb = TypeA | TypeB;
@TypeGraphQL.ObjectType()
export class SomeRandomType {
__typename?: 'someRandomType';
@TypeGraphQL.Field(type => TypeAb, { nullable: true })
// ^ This is a type, not a class
typeAB!: Maybe<TypeAb>;
};
@charlypoly any reason for removing the confirmed tag ? You can reproduce this is https://www.graphql-code-generator.com/ by pasting the above graphql schema.
Tried to reproduce this in codesandbox but for some reason it was giving me 502, either way, this one should work: https://codesandbox.io/s/sharp-austin-94tiqe?file=/schema.graphql
Hey @dotansimha @Ranguna @ryall, you have any updates on this one? Work around? Fix? Thanks in advance!
Describe the bug
When generating TypeGraphQL, using a union type, the type passed to `@TypeGraphQL.Field` fails with the error: `'Step' only refers to a type, but is being used as a value here. (TS 2693)` **To Reproduce** Steps to reproduce the behavior: Run the generation below.codegen.yml
config file:Expected behavior
No error. To fix this, it probably needs a union type generated: https://typegraphql.com/docs/unions.html
Environment:
@graphql-codegen/...
: 1.21.3Additional context