-
Notifications
You must be signed in to change notification settings - Fork 79
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
Selection set returns incomplete data (Gen2) #2368
Comments
Hi @MKlaeui thanks for raising this issue and providing reproduction steps. We've reproduced internally and marked as a bug for further investigation by the team. |
@MKlaeui these issues have now been fixed. Since you're using a dev preview version of the library, you'll need to perform the following steps:
"dependencies": {
"aws-amplify": "^6.3.6",
...
},
"devDependencies": {
"@aws-amplify/backend": "^1.0.4",
"@aws-amplify/backend-cli": "^1.1.0",
...
}
const schema = a.schema({
ExperienceEnum: a.enum(['Great', 'Ok', 'Mediocre', 'Lousy']),
AlphabetEnum: a.enum(['A', 'B', 'C', 'D']),
Address: a.customType({
street: a.string(),
city: a.string(),
}),
CustomerDetails: a.customType({
address: a.ref('Address'),
since: a.datetime().required(),
}),
Verbiage: a.customType({
name: a.ref('AlphabetEnum').required(),
paragraphs: a.string().required().array().required(),
}),
Part: a
.model({
name: a.string().required(),
orders: a.hasMany('CustomerPart', 'partId'),
})
.authorization((allow) => [allow.owner()]),
Customer: a
.model({
name: a.string().required(),
verbiage: a.ref('Verbiage').required().array().required(),
orders: a.hasMany('CustomerPart', 'customerId'),
})
.authorization((allow) => [allow.owner()]),
CustomerPart: a
.model({
customerDetails: a.ref('CustomerDetails'),
experience: a.ref('ExperienceEnum'),
customer: a.belongsTo('Customer', 'customerId'),
customerId: a.string(),
part: a.belongsTo('Part', 'partId'),
partId: a.string(),
})
.authorization((allow) => [allow.owner()]),
}); Please let us know if you run into any issues with updating. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Thanks for this update. This looks great. One thing that I noticed as still off (and wasn't in my original example) is that an optional array of custom types return a single instance or null instead of an array or null. For example, if I changed the Customer model to "verbiage: a.ref('Verbiage').required().array()," I get back verbiage | null instead of verbiage[] | null |
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
20.10.0
Amplify CLI Version
@aws-amplify/[email protected] @aws-amplify/[email protected]
What operating system are you using?
Chromebook/Linux
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
none
Describe the bug
Selection Set returns unexpected data when querying custom types and arrays. Also, cannot retrieve foreign keys of many-to-many tables. I'm assuming reading the key from the "other side" table (part) would take longer and cost more.
Expected behavior
Reproduction steps
ExperienceEnum: a.enum(['Great', 'Ok', 'Mediocre', 'Lousy']),
AlphabetEnum: a.enum(['A', 'B', 'C', 'D']),
Address: a.customType({
street: a.string(),
city: a.string(),
}),
CustomerDetails: a.customType({
address: a.ref('Address'),
since: a.datetime().required(),
}),
Verbiage: a.customType({
name: a.ref('AlphabetEnum').required(),
paragraphs: a.string().required().array().required(),
}),
Part: a
.model({
name: a.string().required(),
orders: a.hasMany('CustomerPart'),
})
.authorization([a.allow.owner(),]),
Customer: a
.model({
name: a.string().required(),
verbiage: a.ref('Verbiage').required().array().required(),
orders: a.hasMany('CustomerPart'),
})
.authorization([a.allow.owner(),]),
CustomerPart: a
.model({
customerDetails: a.ref('CustomerDetails'),
experience: a.ref('ExperienceEnum'),
customer: a.belongsTo('Customer'),
part: a.belongsTo('Part'),
})
.authorization([a.allow.owner(),]),
});
3. ```
const { data: customerSet } = await client.models.Customer.list({
selectionSet: ['id', 'name', 'verbiage.', 'orders.', /* orders.partOrdersId, */ 'orders.part.id']
});
Put your logs below this line
The text was updated successfully, but these errors were encountered: