You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
v18.15.0
Amplify CLI Version
11.0.3
What operating system are you using?
Windows
Amplify Codegen Command
codegen
Describe the bug
During code generation for typescript types, a union causes type generation to fail due to conflicting types on the schema
Expected behavior
It generates the correct graphqlTypes.ts without issue for conflicting types. If necessary provide configuration to turn off graphql validation for this rule
# Put your logs below this line
- Generating.../XX/graphql/queries.ts: Fields "value" conflict because they return conflicting types "String" and "Complex". Use different aliases on the fields to fetch both if this was intentional.
.../XX/graphql/queries.ts: Fields "value" conflict because they return conflicting types "String" and "Complex". Use different aliases on the fields to fetch both if this was intentional.
✖ Validation of GraphQL query document failed
Additional information
Here is the output with graphql validation turned off. This is what I want
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
export type Unioned = Simple | More_Complex
export type Simple = {
__typename: "Simple",
value?: string | null,
};
export type More_Complex = {
__typename: "More_Complex",
value?: Complex | null,
};
export type Complex = {
__typename: "Complex",
foo?: string | null,
};
export type GetQuery = {
get: Array<( {
__typename: "Simple",
value?: string | null,
} | {
__typename: "More_Complex",
value?: {
__typename: string,
foo?: string | null,
} | null,
}
) | null > | null,
};
The text was updated successfully, but these errors were encountered:
Hi @SorsOps, thank you for reaching out. Today I believe this restriction exists because the underlying transformer which this codegen was based on does not support union types or interfaces, but it's possible we can restrict the validation here (especially if you're not using the Amplify CLI to define or push your GraphQL API). I've marked this as a feature request.
Before opening, please confirm:
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
v18.15.0
Amplify CLI Version
11.0.3
What operating system are you using?
Windows
Amplify Codegen Command
codegen
Describe the bug
During code generation for typescript types, a union causes type generation to fail due to conflicting types on the schema
Expected behavior
It generates the correct
graphqlTypes.ts
without issue for conflicting types. If necessary provide configuration to turn off graphql validation for this ruleReproduction steps
amplify codegen
GraphQL schema(s)
Log output
Additional information
Here is the output with graphql validation turned off. This is what I want
The text was updated successfully, but these errors were encountered: