graphql-transformer does not generate enum fields when the item in a nested query.
See original GitHub issueDescribe the bug When using query to get a data A which contains list of another data type B. The type B has an Enum value. The Enum type is missing in the generated queries.js.
To Reproduce Steps to reproduce the behavior:
And here is the entirety of my amplify/backend/api/appsynctestapp/build/schema.graphql:
type Recipe @model {
id: ID!
title: String!
description: String!
ingredients: [String]
instructions: [String]
photos: [Photo] @connection(name: "RecipePhotosConnection")
pack: Pack @connection(name: "PackRecipesConnection")
}
type Photo @model {
id: ID!
title: String!
description: String
url: String!
type: PhotoType
primary: Boolean
recipe: Recipe @connection(name: "RecipePhotosConnection")
}
type Pack @model {
id: ID!
title: String!
description: String!
recipes: [Recipe] @connection(name: "PackRecipesConnection")
}
enum PhotoType {
PHOTO_TYPE_SMALL
PHOTO_TYPE_LARGE
}
After calling Amplify codegen
I noticed that the ENUM PhotoType (filenname “type”) in my Photo objects was not being returned when I made queries using graphqlOperation. I can see that it’s present when I query specifically for Photo (getPhoto), but not when I query for Recipe (getRecipe), which has a one-to-many relationship with Photo. Here are the generated queries from src/graphql/queries.js in my amplify project:
export const getPhoto = `query GetPhoto($id: ID!) {
getPhoto(id: $id) {
id
title
description
url
type
primary
recipe {
id
title
description
ingredients
instructions
}
}
}
`;
export const getRecipe = `query GetRecipe($id: ID!) {
getRecipe(id: $id) {
id
title
description
ingredients
instructions
photos {
items {
id
title
description
url
primary
}
nextToken
}
pack {
id
title
description
}
}
}
`;
Expected behavior When generate the code of getRecipe, the photo should contain the PhotoType value.
Desktop (please complete the following information):
- OS: MAC - JavaScript, React
Additional context npm list -g graphql-versioned-transformer /usr/local/lib └─┬ @aws-amplify/cli@0.1.38 └─┬ amplify-provider-awscloudformation@0.1.38 └── graphql-versioned-transformer@1.0.34
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5

Top Related StackOverflow Question
Just copy them over from the single item query so they match. See my code above where you would copy
votes { … }fromgetItemand paste it insideoptions { … }inlistItems.In the meantime, is there a manual workaround that will persist after codegen? (Other than changing the type to a String, which is what I’ll do for now.)