Open
Description
** Which Category is your question related to? **
API
** What AWS Services are you utilizing? **
AWS Appsync SDK
** Provide additional details e.g. code snippets **
How do you get AWS Appsync Optimistic Response to work when your models have relationships using @connection?
The generated mutation input fields don't take "jobs" as input but the optimistic response requires it to work. I get this warning that says: Missing field jobs in { "__typename": "User"...}
My User model uses @connection to connect users with jobs.
type User
@model
@key(fields: ["tenantId", "userId"])
{
tenantId: String!
userId: ID!
...
jobs: [JobAssignee] @connection(name: "UserJobs", keyField: "userId")
}
My react component setup:
export default compose(
graphql(ListUsers, {
options: {
fetchPolicy: 'cache-and-network',
variables: {
limit: 100
}
},
props: (props: any) => ({
users: props.data.listUsers ? props.data.listUsers.items : [],
data: props.data
})
}),
graphqlMutation(NewUser, ListUsers, 'User', 'userId'),
graphqlMutation(EditUser, ListUsers, 'User', 'userId')
)(Users);