-
Notifications
You must be signed in to change notification settings - Fork 161
Cursor Reconfigure For Order #165
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
Conversation
|
👏 |
|
Travis isn't currently running the integration tests since a unit test fails (looks like it might be related to a graphql update, not sure). |
lib/argsToFindOptions.js
Outdated
| return result; | ||
| } | ||
|
|
||
| module.exports = exports['default']; No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/ should be in gitignore, either way please remove from PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the lib folder to this so i could use it straight from github for our application. I can remove it directly before its ready for merge. If you have an alternative suggestion to make this able to be installed from github so we can install versions that aren't ready for NPM for testing etc i'd love to implement that feature.
We use automated build processes on heroku so we are limited to what can be automatically installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm alright, please do remove before we merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
|
I've fixed the unit test, please rebase. |
|
I generally like the approach of encoding the index in the cursor and then using that index. |
|
I'm not familiar with that part of it. Could I alter the mutation test to account for this and add some tests in their for resulting order? Though I do believe that some of that would need to be handled on the client side in the relay mutation configuration using the fields config? Give me some guidance and i can work towards a test case that fails and then work on a resolution. |
|
I was thinking more of changes to rows from outside graphql-relay. |
| ELSE "updatedAt" End ASC`); | ||
| } | ||
| return options; | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simply add the literal to the value of the ENUM i believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't work for me because literal returns an object with {val : }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, i believe i have that in one of my projects. Having an object shouldn't matter, the value in ENUM can be anything AFAIR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let orderBy = args.orderBy;
let orderAttribute = orderByAttribute(orderBy);
let orderDirection = args.orderBy[0][1];```
specifically this part of the connections configuration prevents that case because its looking directly for an array value. I tried setting it up directly in the order configuration first and it failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah alright, was sure i tried that out, but maybe i used a hook too.
|
@brad-decker Any update? |
|
Do we even need to care about id in the cursor with this update? We could possible just move to the cursor generators provided by graphql-relay |
|
hey guys, what's the current status of this? |
|
@brad-decker has been unavailable for a bit, waiting for him to be back. Do you have a usecase not solved by the current method @chrisbolin? |
|
I hit #170, which led me here :) |
|
Ah, i didn't actually envision seeing a lot of MSSQL users i must admit :) |
|
Oh, I'm on Postgres. |
|
e.g. the if you have an |
|
actually, looking at the code closely, it looks like |
|
@chrisbolin @mickhansen sorry for the delay... No promises but i should be able to work on this this week. |
|
no worries, @brad-decker! Thanks for taking a stab at this. |
|
I think this is probably related to the "where": {
"$or": [
{
"id": {
"$lt": "103"
}
},
{
"id": {
"$gt": "103"
}
}
]
},For |
|
@chrisbolin Hmm yeah, full count is affected by where, odd i haven't encountered this since we do filter by id/order value. |
|
All in all @brad-decker's update should work better. Not sure why i ruled out index in cursor as a proper fix in the beginning. |
|
@mickhansen can you do a final review of this and then i'll put our project that is using our fork on pause and remove the lib folder from the repository so you can merge. sorry for such a long delay on this. |
|
@brad-decker IIRC i was quite happy with most of it, however the diff is near impossible at the moment. |
|
@mickhansen rebased and removed lib. I've got a failing test that was added in the relay test file regarding model connections that i have to figure out but i'll get on it shortly. |
|
Still like 30-40 commits in the PR including merge commits. |
|
Hmm |
|
Ok successfully rebased, need to do some cleanup tho and fix that test still. Sorry about the false alarm there |
|
Cleanup done, test passing. |
src/relay.js
Outdated
| /** | ||
| * Creates a cursor given a item returned from the Database | ||
| * @param {Object} item sequelize model instance | ||
| * @param {Integer} index the index of this item within the results, 1 indexed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0 indexed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
@mickhansen most of your points have been addressed now. Thanks for the feedback |
|
|
||
| it('should support nested aliased fields', async function () { | ||
| let result = await graphql(this.schema, ` | ||
| it('should support in-query slicing with user provided args/where', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this test was changed although i don't think it was intentional.
Signed-off-by: brad-decker <bhdecker84@gmail.com> removed defaultOrderBy for lint Signed-off-by: brad-decker <bhdecker84@gmail.com> make graphql-sequelize useable from github Signed-off-by: brad-decker <bhdecker84@gmail.com> build should use internal version of babel Signed-off-by: brad-decker <bhdecker84@gmail.com> use internal node_modules version take 2 Signed-off-by: brad-decker <bhdecker84@gmail.com> Remove postinstall, add lib folder temporarily Signed-off-by: brad-decker <bhdecker84@gmail.com> Cursor Reconfigure For Order Signed-off-by: brad-decker <bhdecker84@gmail.com> make graphql-sequelize useable from github Signed-off-by: brad-decker <bhdecker84@gmail.com> build should use internal version of babel Signed-off-by: brad-decker <bhdecker84@gmail.com> use internal node_modules version take 2 Signed-off-by: brad-decker <bhdecker84@gmail.com> Remove postinstall, add lib folder temporarily Signed-off-by: brad-decker <bhdecker84@gmail.com> Cursor Reconfigure For Order Signed-off-by: brad-decker <bhdecker84@gmail.com> make graphql-sequelize useable from github Signed-off-by: brad-decker <bhdecker84@gmail.com> build should use internal version of babel Signed-off-by: brad-decker <bhdecker84@gmail.com> use internal node_modules version take 2 Signed-off-by: brad-decker <bhdecker84@gmail.com> Remove postinstall, add lib folder temporarily Signed-off-by: brad-decker <bhdecker84@gmail.com> Cursor Reconfigure For Order Signed-off-by: brad-decker <bhdecker84@gmail.com> make graphql-sequelize useable from github Signed-off-by: brad-decker <bhdecker84@gmail.com> build should use internal version of babel Signed-off-by: brad-decker <bhdecker84@gmail.com> use internal node_modules version take 2 Signed-off-by: brad-decker <bhdecker84@gmail.com> Remove postinstall, add lib folder temporarily Signed-off-by: brad-decker <bhdecker84@gmail.com> Weird conflict issue, fixing. Signed-off-by: brad-decker <bhdecker84@gmail.com> add one to startIndex if its not 0 to account for 0 indexed cursor Signed-off-by: brad-decker <bhdecker84@gmail.com> update tests to match results Signed-off-by: brad-decker <bhdecker84@gmail.com> fixing test Signed-off-by: brad-decker <bhdecker84@gmail.com> Cursor Reconfigure For Order Signed-off-by: brad-decker <bhdecker84@gmail.com> removed defaultOrderBy for lint Signed-off-by: brad-decker <bhdecker84@gmail.com> make graphql-sequelize useable from github Signed-off-by: brad-decker <bhdecker84@gmail.com> build should use internal version of babel Signed-off-by: brad-decker <bhdecker84@gmail.com> use internal node_modules version take 2 Signed-off-by: brad-decker <bhdecker84@gmail.com> Remove postinstall, add lib folder temporarily Signed-off-by: brad-decker <bhdecker84@gmail.com> Cursor Reconfigure For Order Signed-off-by: brad-decker <bhdecker84@gmail.com> make graphql-sequelize useable from github Signed-off-by: brad-decker <bhdecker84@gmail.com> build should use internal version of babel Signed-off-by: brad-decker <bhdecker84@gmail.com> use internal node_modules version take 2 Signed-off-by: brad-decker <bhdecker84@gmail.com> Remove postinstall, add lib folder temporarily Signed-off-by: brad-decker <bhdecker84@gmail.com> Cursor Reconfigure For Order Signed-off-by: brad-decker <bhdecker84@gmail.com> removed defaultOrderBy for lint Signed-off-by: brad-decker <bhdecker84@gmail.com> make graphql-sequelize useable from github Signed-off-by: brad-decker <bhdecker84@gmail.com> build should use internal version of babel Signed-off-by: brad-decker <bhdecker84@gmail.com> use internal node_modules version take 2 Signed-off-by: brad-decker <bhdecker84@gmail.com> Remove postinstall, add lib folder temporarily Signed-off-by: brad-decker <bhdecker84@gmail.com> Cursor Reconfigure For Order Signed-off-by: brad-decker <bhdecker84@gmail.com> removed defaultOrderBy for lint Signed-off-by: brad-decker <bhdecker84@gmail.com> make graphql-sequelize useable from github Signed-off-by: brad-decker <bhdecker84@gmail.com> build should use internal version of babel Signed-off-by: brad-decker <bhdecker84@gmail.com> use internal node_modules version take 2 Signed-off-by: brad-decker <bhdecker84@gmail.com> Remove postinstall, add lib folder temporarily Signed-off-by: brad-decker <bhdecker84@gmail.com> Weird conflict issue, fixing. Signed-off-by: brad-decker <bhdecker84@gmail.com> add one to startIndex if its not 0 to account for 0 indexed cursor Signed-off-by: brad-decker <bhdecker84@gmail.com> update tests to match results Signed-off-by: brad-decker <bhdecker84@gmail.com> removed lib Signed-off-by: brad-decker <bhdecker84@gmail.com> Cleanup, fixed tests Signed-off-by: brad-decker <bhdecker84@gmail.com> Making requested Changes Signed-off-by: brad-decker <bhdecker84@gmail.com> renaming cursor to queriedCursor Signed-off-by: brad-decker <bhdecker84@gmail.com> rebase messed up some tests. replacing them Signed-off-by: brad-decker <bhdecker84@gmail.com> fixing one more test. Signed-off-by: brad-decker <bhdecker84@gmail.com>
|
Thanks @KATT @chrisbolin @mickhansen and everyone else for your patience here. 👏 |
|
Amazing!! Thank you so much for all the the time & effort you both put into this @mickhansen + @brad-decker! Can't wait to try it out. |
Updates
Caveats
Signed-off-by: brad-decker bhdecker84@gmail.com