Skip to content
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

Mutation request must contains all data required in list query. In other case list will not be updated #407

Open
MichalKalita opened this issue May 15, 2019 · 3 comments
Labels
appsync-core Related to core updates within AppSync SDK to-be-reproduced We need to reproduce this issue

Comments

@MichalKalita
Copy link

MichalKalita commented May 15, 2019

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
I have query like that

query ListItems {
  listItems(limit: 9999) {
    items {
      __typename
      id
      title
      owner
      createdAt
      updatedAt
    }
    nextToken
  }
}

And mutation like that

mutation CreateItem($input: CreateItemInput!) {
  createItem(input: $input) {
    id
    title
    owner
    createdAt
    updatedAt
  }
}

CreateItemInput have required only title other params are optional.

When mutation is executed, list is not updated because of missing parameters owner, createdAt and updatedAt.

In console is warning with information about missing parameters.

Source code looks like that

compose(
  graphql(listItems, {
    options: {
      fetchPolicy: "cache-and-network"
    },
    props: props => {
      return {
        items: props.data.listItems ? props.data.listItems.items : []
      };
    }
  }),
  graphqlMutation(CreateList, listItems, "Item"),
)(ReactComponentRenderingList);

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

It is a bug because in mutation response are all required parameters. List update works only with request and ignore data from response.

This functionality have weird behavior with offline > online client transition

  1. Create item function is called when website is offline
  2. Item list is not updated
  3. Website goes online
  4. Mutation is send to backend, list is updated with data from response.
    But when client is online whole time, data from response are not used.

Problem can be fixed when mutation is called with all parameters. In this case item is added to list immediately.

What is the expected behavior?

  1. Mutation with variables is executed.
  2. If mutation request contains all required parameters to list query, list will be updated immediately.
  3. In all cases program must wait for response and use data from response to update list. (Like offline > online transition)

Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions?

Chrome 74
aws-appsync@1.7.2
aws-appsync-react@1.2.7
react-apollo@2.5.4

@kjlis
Copy link

kjlis commented Jun 15, 2019

The same issue occurs in #349

@juliancode
Copy link

Can anyone point me in the right direction around this? I want to get optimistic UI updates but I'm guessing the graphqlMutation isn't the way to go anymore? I've heard some talk about buildMutation but docs still suggest this?

Thanks

@elorzafe elorzafe added appsync-core Related to core updates within AppSync SDK to-be-reproduced We need to reproduce this issue labels Apr 15, 2020
@santi8194
Copy link

Any updates? I'm still having this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appsync-core Related to core updates within AppSync SDK to-be-reproduced We need to reproduce this issue
Projects
None yet
Development

No branches or pull requests

5 participants