Describe the bug
When generating the Swift SDK from my graphql schema, subentities on an entity do not have all their fields in the generated query string inside the created API file.
To Reproduce
Steps to reproduce the behavior:
type Member {
id: ID!
version: Int!
label: String
avatar: AWSURL
phone: String!
}
type Moment {
id: ID!
version: Int!
status: String!
from: Participation!
event: Event!
featuredTag: String
tags: [String!]
caption: String
photo: AWSURL
fallback: AWSURL
quote: String
background: AWSURL
}
input MomentFilterInput {
event: ID
member: ID
participation: ID
featuredTag: String
tags: [String!]
status: [String!]
}
type Participation {
id: ID!
version: Int!
member: Member!
event: Event!
role: String!
designation: String
status: String!
}
type Query {
getMoment(id: ID!): Moment
listMoments(filter: MomentFilterInput): [Moment!]
}
schema {
query: Query
}
````
amplify add codegen --apiId 123TheApiKey
....
````
Expected behavior
I expected that in the above query string I would see the member
field on a participation (the from
).
This is a pretty major problem because it means I can only have entities that are very shallow OR I have to do all the bookkeeping of ID referencing myself. Am I misunderstanding how to use the API here?
@MageMasher amplify codegen by default limits the number level it traverses in response type. This is done to prevent an infinite loop if a type refers to itself. We don't have a way to change the depth using CLI, but we might implement a way to pass that in the future.
amplify codegen is 2 step process
swift
or typescript
files.So to solve the issue you have you could update the statements generated in step 1. The files are located inside <proj-directory>/graphql
to include members
subfield. After doing that make sure say no to Do you want to generate/update all possible GraphQL operations - queries, mutations and subscriptions
and the generated code will have memebers.
Is this two step process documented somewhere? I almost gave up on appsync entirely because of this issue and after scouring the documentation for well over 2 days I filed this issue because I couldn't figure out why it was behaving like this.
To be clear, I'm thrilled there is a known solution here, I just hope more folks find this issue rather than give up like I almost did. Thank you for your help.
Is this two step process documented somewhere? I almost gave up on appsync entirely because of this issue and after scouring the documentation for well over 2 days I filed this issue because I couldn't figure out why it was behaving like this.
No its not documented anywhere. I have created an https://github.com/aws-amplify/docs/issues/199 in our documentation repo.
Most helpful comment
Is this two step process documented somewhere? I almost gave up on appsync entirely because of this issue and after scouring the documentation for well over 2 days I filed this issue because I couldn't figure out why it was behaving like this.
To be clear, I'm thrilled there is a known solution here, I just hope more folks find this issue rather than give up like I almost did. Thank you for your help.