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

fix(GraphQL): fix graphql mutations not returning updated information #6130

Merged
merged 1 commit into from
Oct 14, 2019

Conversation

omairvaiyani
Copy link
Contributor

This issue occurs when an updated field is modified in beforeSave, but the unmodified version is returned if requested by the resolver.

For example

mutation UpdateTitle($id: ID!, $title: String!) {
  updateSomeObject(id: $id, fields: { title: $title }) {
      id
      title
      slug
  }
}

In the above, if we modify the title by let's say, trimming it - the resolved title will not reflect this change, and instead just return the input variable. Other resolved fields that are not sent within the fields input are returned properly using the latest data.

This issue was spotted when an updated field is modified in beforeSave, but the unmodified version is returned if requested by the resolver.

For example
```grapqhl
mutation UpdateTitle($id: ID!, $title: String!) {
  updateSomeObject(id: $id, fields: { title: $title }) {
      id
      title
      slug
  }
}
```

In the above, if we modify the `title` by let's say, trimming it - the resolved `title` will not reflect this change, and instead just return the input variable. Other resolved fields that are not sent within the `fields` input are returned properly using the latest data.
@codecov
Copy link

codecov bot commented Oct 13, 2019

Codecov Report

Merging #6130 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6130      +/-   ##
==========================================
- Coverage   93.73%   93.72%   -0.01%     
==========================================
  Files         165      165              
  Lines       11210    11210              
==========================================
- Hits        10508    10507       -1     
- Misses        702      703       +1
Impacted Files Coverage Δ
src/GraphQL/loaders/parseClassMutations.js 100% <100%> (ø) ⬆️
src/Adapters/Storage/Mongo/MongoStorageAdapter.js 92.27% <0%> (-0.71%) ⬇️
src/RestWrite.js 93.72% <0%> (+0.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 44c77fa...45cf2a6. Read the comment docs.

Copy link
Contributor

@douglasmuraoka douglasmuraoka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@douglasmuraoka douglasmuraoka merged commit b709150 into master Oct 14, 2019
@omairvaiyani omairvaiyani deleted the omairvaiyani-graphql-mutation-fix branch October 15, 2019 13:37
UnderratedDev pushed a commit to UnderratedDev/parse-server that referenced this pull request Mar 21, 2020
…unity#6130)

This issue was spotted when an updated field is modified in beforeSave, but the unmodified version is returned if requested by the resolver.

For example
```graphql
mutation UpdateTitle($id: ID!, $title: String!) {
  updateSomeObject(id: $id, fields: { title: $title }) {
      id
      title
      slug
  }
}
```

In the above, if we modify the `title` by let's say, trimming it - the resolved `title` will not reflect this change, and instead just return the input variable. Other resolved fields that are not sent within the `fields` input are returned properly using the latest data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants