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

Unable to Fetch Custom Data Types in Lambda using Generated GraphQL Queries #3085

Open
amirpoudel opened this issue Dec 19, 2024 · 1 comment

Comments

@amirpoudel
Copy link

amirpoudel commented Dec 19, 2024

Environment information

npx ampx info

Data packages

npm list @aws-amplify/data-construct @aws-amplify/graphql-schema-generator

Description

I am using amplify gen2 lambda function
I am unable to retrieve data for custom data types defined in my schema while performing list operations In Lambda function. Specifically, I cannot access data inside the PurchasedTickets custom type when querying for Ticket objects. Other fields in the Ticket model are accessible, but the purchasedTickets array (which uses the custom type) .

Custom Types and Models
Here is the relevant part of my schema:

PurchasedTickets: a.customType({
code: a.id().required(),
category: a.string(),
price: a.float(),
}),

Ticket: a.model({
id: a.id().required(),
type: a.string().default('Ticket').required(),
eventId: a.id().required(),

purchasedTickets: a.ref('PurchasedTickets').array(), // Custom data type
totalPurchaseTickets: a.integer(),
totalPurchaseAmount: a.float(),

}),
Generated GraphQL Query
The following is the query generated for listing Ticket objects:

export const listTicketByEventIdCreatedAt = /* GraphQL */ `query ListTicketByEventIdCreatedAt(
$createdAt: ModelStringKeyConditionInput
$eventId: ID!
$filter: ModelTicketFilterInput
$limit: Int
$nextToken: String
$sortDirection: ModelSortDirection
) {
listTicketByEventIdCreatedAt(
createdAt: $createdAt
eventId: $eventId
filter: $filter
limit: $limit
nextToken: $nextToken
sortDirection: $sortDirection
) {
items {
createdAt
eventId
id

  totalPurchaseTickets
  totalPurchaseAmount

  # Missing: purchasedTickets field (custom data type)
  __typename
}
nextToken
__typename

}
}
`;
Problem
The purchasedTickets field, which references the custom type PurchasedTickets, is missing in the items section of the generated GraphQL query. While all other fields in the Ticket model are present, I cannot fetch or use the data for purchasedTickets in my queries.

Environment
Backend: Separate backend repository
Frontend: Separate frontend repository
GraphQL: Using automatically generated queries
Screenshot 2024-12-20 004818

@AnilMaktala
Copy link
Member

Hey @amirpoudel, Thank you for bringing this to our attention. We’ll work on reproducing the issue and keep you updated.

@AnilMaktala AnilMaktala added the to-be-reproduced Pending reproduction label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants