Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fixed a server crash that occourred if an entity property is named `localized`.
- A bug where the field `totalCount` could not be queried on its own
Copy link
Contributor

@David-Kunz David-Kunz Jan 24, 2023

Choose a reason for hiding this comment

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

Suggested change
- A bug where the field `totalCount` could not be queried on its own
- The field `totalCount` could not be queried on its own


### Removed

Expand Down
5 changes: 2 additions & 3 deletions lib/resolvers/parse/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ const _filterOutDuplicateColumnsSelections = selections => {
}

const getPotentiallyNestedNodesSelections = selections => {
const nodesSelections = selections.filter(selection => selection.name.value === CONNECTION_FIELDS.nodes)
if (nodesSelections.length === 0) return selections
return _filterOutDuplicateColumnsSelections(selections)
const isConnection = selections.some(selection => Object.values(CONNECTION_FIELDS).includes(selection.name.value))
return isConnection ? _filterOutDuplicateColumnsSelections(selections) : selections
}

module.exports = { getPotentiallyNestedNodesSelections }
21 changes: 21 additions & 0 deletions test/tests/queries/totalCount.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ describe('graphql - queries with totalCount', () => {
expect(response.data).toEqual({ data })
})

test('query selecting only totalCount', async () => {
const query = gql`
{
AdminService {
Books {
totalCount
}
}
}
`
const data = {
AdminService: {
Books: {
totalCount: 5
}
}
}
const response = await POST('/graphql', { query })
expect(response.data).toEqual({ data })
})

test('query with totalCount and simple filter', async () => {
const query = gql`
{
Expand Down