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

Remove "And", "Or", and Relationships as valid OrderByInput types. #2625

Merged
merged 6 commits into from
Mar 26, 2025

Conversation

aaronburtle
Copy link
Contributor

@aaronburtle aaronburtle commented Mar 20, 2025

Why make this change?

Closes #2286

What is this change?

The InputTypeBuilder class holds a function called GenerateOrderByInputTypeForObjectType, which is responsible for populating the GraphQL Schema with the valid OrderByInput types. It was mistakenly adding in "and", "or", and columns that are in entities associated through relationships as valid OrderByInput types. "and" and "or" will never be valid input types, and we do not yet support order by using columns from related entities.

How was this tested?

Manually verified that the correct error was returned when trying to use the incorrect orderBy queries, and manually verified that we no longer have them in the schema.

Added regression test to verify we get an error when attempting these queries.

Sample Request(s)

These are some example graph QL queries that are invalid but were showing as valid in our schema without this fix.

publishers (first: 5 orderBy: {books: { title: DESC }}){
items {
id
books {
items {
title
}
}
}
}

books(orderBy: { or: { id: ASC, title: ASC } }) {
items {
id
}
}

@aaronburtle
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@aaronburtle
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 6 pipeline(s).

Copy link
Contributor

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@RubenCerna2079 RubenCerna2079 left a comment

Choose a reason for hiding this comment

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

lgtm

@RubenCerna2079
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@aaronburtle
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@aaronburtle aaronburtle merged commit 4d7207e into main Mar 26, 2025
11 checks passed
@aaronburtle aaronburtle deleted the dev/aaronburtle/OrderByAndOrBugFix branch March 26, 2025 21:11
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.

[Bug]: orderBy clause has support for OR/AND operator and relationship fields which do not work
3 participants