amplify-codegen
amplify-codegen copied to clipboard
Confusion about max-depth and custom graphql types
Hi, I'm a bit confused over the expected functionality of codegen --max-depth and custom types. I found this issue (https://github.com/aws-amplify/amplify-cli/issues/1064) and this PR (https://github.com/aws-amplify/amplify-cli/pull/1068) and wondered if this related so S3Object types?
If you create the schema from the following snippet below which is from your docs, the generated ListTodos would not include file in the items with the default max depth of 2. This is because codegen does not include file for ListTodos but it does include it for the singular GetTodo query. Is this correct or should the codegen command be including file for the ListTodos collection query?
Which Category is your question related to? codegen
Amplify CLI Version 6.3.1
What AWS Services are you utilizing? AppSync, S3
Provide additional details e.g. code snippets
type Todo @model {
id: ID!
name: String!
description: String!
file: S3Object
}
type S3Object {
bucket: String!
key: String!
region: String!
}
Hi @benjamindoe,
For the time being I think your best option is to configure your maximum depth to 3 to allow your requests to work.
I will transfer this to amplify-codegen so they can look at this
Thanks @marcvberg. Max depth 3 is fine for now but it would be good to reduce the amount of data transferred over the wire if possible
Marking this as a request for an enhancement.
I came looking for a similar problem. When I use a huge depth (7), the data (in the deeper leaves) is missing because naturally my data is not that deep. So, seeing some errors though data is returned alright.
Amplify Version: 9.2.1
type Player @model {
...
events: [Event] @manyToMany(relationName:"PlayerEventReg")
...
}
type Event @model {
...
players: [Player] @manyToMany(relationName:"PlayerEventReg")
...
}
Partly the reason being the link table generated as follows
type PlayerEventReg {
id: ID!
playerID: ID!
eventID: ID!
player: Player!
event: Event!
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
}
This also actually looks OK. But that if events in the type Player is not created yet? The Player object data for getPlayer / listPlayers should not complain for events i.e., it should be allowed to be null. But it seems to complain.
Cannot return null for non-nullable type: 'Event' within parent 'PlayerEventReg' (/listPlayers/items[0]/events/items[0]/event)"