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

Excluding keys that have trailing "edges.node" on them #7273

Merged

Conversation

cjbland
Copy link
Contributor

@cjbland cjbland commented Mar 17, 2021

New Pull Request Checklist

Issue Description

The issue is trying to call resolvers on relations do not work with Postgres. For example the following query will fail when using Posgres:

roles(where: { users: { have: { id: { equalTo: $userId } } } }) {
  edges {
    node {
      name
      users {
        edges {
          node {
            username
          }
        }
      }
    }
  }
}

Related issue: #6419

Approach

The approach with this PR is to ignore any keys that have a trailing edges.node on them. Using the example above, it will initially have these select keys:

This fails because the following fields are being sent to the resolver:

[
  'edges.node.name',
  'edges.node.users.edges.node.username'
]

This then gets modified down to:

[
  'name',
  'users.edges.node.username'
]

This array gets passed as the "keys" to the REST query. Down the processing chain the RestQuery will chop off everything after the first . so then we're left with ['name', 'users'] and users is not a valid column on the _Role table. This PR will drop the users.edges.node.username key all together as it would never need to be a selected key in any query.

TODOs before merging

  • Add test cases
  • Add entry to changelog
  • Add changes to documentation (guides, repository pages, in-code descriptions)
  • Add security check
  • Add new Parse Error codes to Parse JS SDK
  • ...

@codecov
Copy link

codecov bot commented Mar 17, 2021

Codecov Report

Merging #7273 (c159b5f) into master (637326d) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7273      +/-   ##
==========================================
- Coverage   93.94%   93.89%   -0.05%     
==========================================
  Files         179      179              
  Lines       13152    13154       +2     
==========================================
- Hits        12355    12351       -4     
- Misses        797      803       +6     
Impacted Files Coverage Δ
src/GraphQL/loaders/parseClassQueries.js 98.00% <100.00%> (+0.04%) ⬆️
src/GraphQL/loaders/parseClassTypes.js 94.23% <100.00%> (+0.03%) ⬆️
src/batch.js 91.37% <0.00%> (-1.73%) ⬇️
src/ParseServerRESTController.js 97.01% <0.00%> (-1.50%) ⬇️
src/Adapters/Files/GridFSBucketAdapter.js 79.50% <0.00%> (-0.82%) ⬇️
src/Adapters/Storage/Mongo/MongoStorageAdapter.js 92.59% <0.00%> (-0.66%) ⬇️

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 637326d...c159b5f. Read the comment docs.

@davimacedo
Copy link
Member

Thanks for the PR. Could you please change this test to also run on Postgres so we can make sure it will always work? https://github.com/parse-community/parse-server/blob/master/spec/ParseGraphQLServer.spec.js#L8257

@cjbland
Copy link
Contributor Author

cjbland commented Mar 17, 2021

Any recommendation on how I could test this locally? I'm a little confused as to why it's only failing on that one version of Postgres and I'd like to avoid pushing debug changes over and over.

@davimacedo
Copy link
Member

Something like:

export PARSE_SERVER_TEST_DB=postgres
export PARSE_SERVER_TEST_DATABASE_URI=your_local_postgres_uri
npm run testonly

Copy link
Member

@davimacedo davimacedo left a comment

Choose a reason for hiding this comment

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

LGTM!

@davimacedo davimacedo merged commit 6313656 into parse-community:master Mar 18, 2021
@cjbland cjbland deleted the bugfix/relation-resolver-postgres branch March 18, 2021 22:41
Arul- pushed a commit to Arul-/parse-server that referenced this pull request Mar 25, 2021
…ty#7273)

* Excluding keys that have trailing "edges.node" on them as they will not be selectable anyway

* Updated CHANGELOG and added test case

* Forgot to change fit back to it
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Nov 1, 2021
@mtrezza mtrezza mentioned this pull request Mar 12, 2022
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants