Skip to content

AWS Appsync Optimistic Response and Models that have relationships using @connection #4090

Open
@amirmishani

Description

@amirmishani

** 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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIRelated to REST API issuesAppSyncRelated to AppSync issuesfeature-requestRequest a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions