Skip to content

Conversation

@gustavlrsn
Copy link
Member

For opencollective/opencollective#8449

Description

  • Adds a createdBy argument to the OrdersCollectionQuery, allowing filtering on who created the order
  • Adds a createdByUsers resolver to the OrdersCollectionQuery, to return a list of who created the orders for the current filters

nodes: {
type: new GraphQLList(GraphQLOrder),
},
createdByUsers: {
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure about the naming, alternative suggestions:

  • creators?
  • createdBy?

Comment on lines 626 to 628
const orderWhereClause = sequelize.queryInterface.queryGenerator
.getWhereConditions(baseWhere, 'o', models.Order)
.replace(/"Order"\./g, 'o.');
Copy link
Member

Choose a reason for hiding this comment

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

I can't find this getWhereConditions in the docs nor in current sequelize's source code. Any link to check what it does and how it's implemented?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a private function in Sequelize v6 (the version we're using): https://github.com/sequelize/sequelize/blob/v6/src/dialects/abstract/query-generator.js#L2846

But you're right, can't find it in v7. Will refactor this.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Betree I've pushed a refactor to use the Sequelize query builder instead of raw sql here, required some tweaks in how to filter is applied compared to the main collection query. The filters are now manually added to createdByUsers resolver, and it is only target those that are relevant to produce the different dashboard tools for now.

@gustavlrsn gustavlrsn force-pushed the feat/orders-created-by-argument branch from 053bf59 to 2acd200 Compare January 6, 2026 13:35
@gustavlrsn gustavlrsn requested a review from Betree January 6, 2026 13:39
@gustavlrsn gustavlrsn force-pushed the feat/orders-created-by-argument branch 2 times, most recently from 0c7c2b3 to 88dd6c1 Compare January 7, 2026 10:59
@gustavlrsn gustavlrsn force-pushed the feat/orders-created-by-argument branch from e61f654 to f97e341 Compare January 7, 2026 12:42
Copy link
Member

@Betree Betree left a comment

Choose a reason for hiding this comment

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

The code looks good to me. Can we add some tests to test/server/graphql/v2/collection/OrdersCollectionQuery.test.ts to cover this new behavior?

@gustavlrsn
Copy link
Member Author

@Betree added some tests for the createdBy argument and the createdByUsers resolver

@gustavlrsn gustavlrsn force-pushed the feat/orders-created-by-argument branch from 5669a92 to 60e9c6d Compare January 8, 2026 12:35
@gustavlrsn gustavlrsn merged commit 6ceb811 into main Jan 8, 2026
20 checks passed
@gustavlrsn gustavlrsn deleted the feat/orders-created-by-argument branch January 8, 2026 14:13
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.

3 participants